Hello,
I am using the latest version of Opencart (1.5.5).
In the Invoice, I would like to remove the appearance of Shipping address if the cart only contains a virtual product.
Can you please guide me on how I can do this?
Thanks.
Regards.
Jason
I am using the latest version of Opencart (1.5.5).
In the Invoice, I would like to remove the appearance of Shipping address if the cart only contains a virtual product.
Can you please guide me on how I can do this?
Thanks.
Regards.
Jason
Note: This is the quickest solution I could see. But not ideally the best. I think a better approach would be for the shipping value to be passed to the 'ocm_order_product' table reducing the need to load in the product module to find out if a product has shipping. But that would require more code and would break current orders as they would not have a value for it.
----
I assume you mean by 'virtual product' all products have 'no shipping'
I shall offer a code solution first and if this is what you want I shall then put it in to a VQmod for you.
My solution checks all products in the order for shipping and if none of them require shipping then the shipping box on the invoice will disappear.
Step 1 - Change Controller
File: admin->controller->sale->order.php
Part A
After: (Around line 2484)
Add:
Part B
After: (Around line 2507)
Add:
Part C
Change: (Around line 2535)
To:
*We just added to the array:
Step 2 - Update Invoice View
File: admin->view->template->sale->order_invoice.tpl
Change: (Around line 54)
To:
Change: (Around Line 71)
To:
*Warning: Changing the default template will mean when you update these changes you will lose this. You should copy the default template and then make these changes. I will make a VQmod if requested but again this will break if in an update these files get changed.
----
I assume you mean by 'virtual product' all products have 'no shipping'
I shall offer a code solution first and if this is what you want I shall then put it in to a VQmod for you.
My solution checks all products in the order for shipping and if none of them require shipping then the shipping box on the invoice will disappear.
Step 1 - Change Controller
File: admin->controller->sale->order.php
Part A
After: (Around line 2484)
Code: Select all
$products = $this->model_sale_order->getOrderProducts($order_id);
Code: Select all
$this->load->model('catalog/product');
$shipping_required = false;
After: (Around line 2507)
Code: Select all
$product_data[] = array(
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'quantity' => $product['quantity'],
'price' => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
'total' => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value'])
);
Code: Select all
$product_info = $this->model_catalog_product->getProduct($product['product_id']);
if($product_info['shipping']) {
$shipping_required = true;
}
Change: (Around line 2535)
Code: Select all
$this->data['orders'][] = array(
'order_id' => $order_id,
....
'comment' => nl2br($order_info['comment'])
);
Code: Select all
$this->data['orders'][] = array(
'order_id' => $order_id,
'invoice_no' => $invoice_no,
'date_added' => date($this->language->get('date_format_short'), strtotime($order_info['date_added'])),
'store_name' => $order_info['store_name'],
'store_url' => rtrim($order_info['store_url'], '/'),
'store_address' => nl2br($store_address),
'store_email' => $store_email,
'store_telephone' => $store_telephone,
'store_fax' => $store_fax,
'email' => $order_info['email'],
'telephone' => $order_info['telephone'],
'shipping_required' => $shipping_required, // ADDED
'shipping_address' => $shipping_address,
'shipping_method' => $order_info['shipping_method'],
'payment_address' => $payment_address,
'payment_company_id' => $order_info['payment_company_id'],
'payment_tax_id' => $order_info['payment_tax_id'],
'payment_method' => $order_info['payment_method'],
'product' => $product_data,
'voucher' => $voucher_data,
'total' => $total_data,
'comment' => nl2br($order_info['comment'])
);
Code: Select all
'shipping_required' => $shipping_required,
File: admin->view->template->sale->order_invoice.tpl
Change: (Around line 54)
Code: Select all
<td width="50%"><b><?php echo $text_ship_to; ?></b></td>
Code: Select all
<?php if($order['shipping_required']) { ?>
<td width="50%"><b><?php echo $text_ship_to; ?></b></td>
<?php } ?>
Code: Select all
<td><?php echo $order['shipping_address']; ?></td>
Code: Select all
<?php if($order['shipping_required']) { ?>
<td><?php echo $order['shipping_address']; ?></td>
<?php } ?>
*Disclaimer: I hope I have been as clear as possible and helpful. If you are unsure of anything please ask I will be happy to help - I do frequently watch the posts I have posted in previously.
How to change prices across a whole multi-store, with a baseline price for each product:
http://forum.opencart.com/viewtopic.php ... 24#p406793
Who is online
Users browsing this forum: No registered users and 16 guests