Adding additional information to cart/order/packing slip
Hi
I posted this already but I think in the wrong part of the forum, so I am reposting it here:
Been reading through this forum and can't find any help. I have the situation where two different products can have the same name, yet are in different categories.
Now my dillema is that on the shopping cart and order and packing slip only the name appears and not the category which it came from (or at least the product id). So far it looks like I need to edit templates. I think I found the files I am suppose to edit:
admin/invoice.php
admin/packingslip.php
includes/templates/MYTEMPLATE/templates/tpl_shopping_cart_default.php (using override)
I tried this in invoice.php:
<td class="dataTableContent" valign="top">' . $order->products[$i]['name'] . $order->products[$i]['id'];
yet to no avail, then I tried this:
<td class="dataTableContent" valign="top">' . $order->products[$i]['name'] . $order->products[$i]['name'];
which resulted in the name being printed twice at the right place, so I am on the right track. Why is 'id' not working?
PS Changing the cart is not critical, however, the invoice and packing slip is. There is no need to display the model on the packing slip or invoice so that can be replaced with category (I am using model for other details and thus can't use it to display the category it is in)
Re: Adding additional information to cart/order/packing slip
Please, anybody have any suggestions? I need this for my shop to wok correctly.
Re: Adding additional information to cart/order/packing slip
OK, tried a bit on my own again. I found this post http://www.zen-cart.com/forum/showth...ct+category%22 with the same problem as me. However, I need my modifications in the packing slip/invoice/cart. I've tried replacing:
$order->products[$i]['model']
with the following:
zen_get_categories_name_from_product($order->products[$i]['products_id'])
zen_get_categories_name_from_product($order->products[$i]['id'])
zen_get_categories_name_from_product($order->products[$i]->fields['products_id'])
zen_get_categories_name_from_product($order->products[$i]->fields['id'])
yet to no avail.
I am really desperate for a solution.
Thanks
Re: Adding additional information to cart/order/packing slip
In the orders class ... you will note that the array contains the following:
PHP Code:
$this->products[$index] = array('qty' => $new_qty,
'name' => $orders_products->fields['products_name'],
'model' => $orders_products->fields['products_model'],
'tax' => $orders_products->fields['products_tax'],
'price' => $orders_products->fields['products_price'],
'onetime_charges' => $orders_products->fields['onetime_charges'],
'final_price' => $orders_products->fields['final_price'],
'product_is_free' => $orders_products->fields['product_is_free']);
There is no products_id stored ...
You would need to alter the orders class to include the products_id in the array in order to use this to display the categories name ...
Re: Adding additional information to cart/order/packing slip
Thank you very much for the help. However, I still seem to be doing something wrong. I changed (in admin/includes/classes/order.php):
'model' => $orders_products->fields['products_model'],
to:
'model' => $orders_products->fields['products_id'],
As it seemed the quickest way to test it and would mean no changes in packing slip or invoice. But still nothing
then I did this:
'id' => $orders_products->fields['products_model'], (in admin/includes/classes/order.php)
and also this (in admin/packingslip.php):
$order->products[$i]['model'] to $order->products[$i]['id']
I am not an expert in PHP and am very sorry if I seem stupid, but hey at least I am trying.
Re: Adding additional information to cart/order/packing slip
I beleive the actual products_id field name in the orders_products table is:
orders_products_id
Re: Adding additional information to cart/order/packing slip
Still no go, orders_products_id seems to give me the id the product has in the orders table, I need the ID of the product in the catalog.
Thanks for the help so far. I am learning a lot from this. Very keen to start learning PHP, although that has to wait for a while.
PS Is there any file I need to include in invoice.php or packingslip.php for zen_get_categories_name_from_product()?
Re: Adding additional information to cart/order/packing slip
Well, I seem to get the idea that the invoice and packing slip part does not seem to have the product id in it's tables.
And it seems it would be a major coding expedition to modify it, thus I have decided to use the model part of the product to display my category. Although not ideal.
This may be a feature that the Zen ppl might want to add later ...
Re: Adding additional information to cart/order/packing slip
Blond moment ... :blink:
Add products_id to:
PHP Code:
$orders_products = $db->Execute("select orders_products_id, products_name, products_model,
products_price, products_tax, products_quantity,
final_price, onetime_charges,
product_is_free,
products_id
from " . TABLE_ORDERS_PRODUCTS . "
where orders_id = '" . (int)$order_id . "'");
And add products_id to:
PHP Code:
$this->products[$index] = array('qty' => $new_qty,
'id' => $orders_products->fields['products_id']
'name' => $orders_products->fields['products_name'],
'model' => $orders_products->fields['products_model'],
'tax' => $orders_products->fields['products_tax'],
'price' => $orders_products->fields['products_price'],
'onetime_charges' => $orders_products->fields['onetime_charges'],
'final_price' => $orders_products->fields['final_price'],
'product_is_free' => $orders_products->fields['product_is_free']);
Then call it in the invoice.php with: $order->products[$i]['id']
Re: Adding additional information to cart/order/packing slip
Thanks. I'll try it out as soon as I get time.