Forums / Setting Up Categories, Products, Attributes / Does the notifier support changing Product Names as they go into the Cart, or Order?

Does the notifier support changing Product Names as they go into the Cart, or Order?

Views: 987

Results 1 to 2 of 2
30 Jun 2011, 5:56 AM
#1
neekfenwick avatar

neekfenwick

New Zenner

Join Date:
Feb 2009
Posts:
101
Plugin Contributions:
0

Does the notifier support changing Product Names as they go into the Cart, or Order?

I have developed a 'spare parts' system for our online shop, at http://www.premierrange.co.uk/index.php?main_page=spares. I'm a pretty capable developer and have been working with ZC for 2 or 3 years now.

Each spare part is an individual product, e.g. products_id = 123 and has a simple name like products_name = 'Glass Canopy'. A more useful product name can be generated by some custom lookups in our database to include the spare part category tree it's in, e.g. "H76 -> 60cm -> Stainless Steel -> Glass Canopy".

http://www.premierrange.co.uk/index.php?main_page=product_spares_info&products_id=278

A quick fix would be to simply store more detailed product names, e.g zen_products_description.products_name = 'H76 -> 60cm -> Stainless Steel -> Glass Canopy' .. I could work around the problems this causes when I need to show just "Glass Canopy" (e.g. on the spares diagram page http://www.premierrange.co.uk/index.php?main_page=spares&cat_path=1_2_6) .. but I'd really like to use the observer system, if possible.

I want to be able to modify the products_name that's put into the Order. Preferably, it should also modify the name seen in the Shopping Cart. So the products_name stays as 'Glass Canopy' in the zen_products_description table, but when you click Add To Cart, you see "H76 -> 60cm -> Stainless Steel -> Glass Canopy" and that's what appears on the order too.

In this way, the customer sees a short name like 'Glass Canopy', and our back office staff see a detailed name that they need to pick the correct item.

1/ for the shopping cart:
I can see that the shopping_cart.php code only stores the products_id, so it only knows which product is in the cart, not its name. The Shopping Cart page gets the name during modules/pages/shopping_cart/header_php.php and only uses it for one-time rendering on the cart page.

I cannot see any notifier/observer hooks in this code. Is it possible to use an observer to modify the product names seen on the Shopping Cart or would we have to hack the core files?

2/ for the order:
And, the order.php code also does not extract the products_name during initialisation - pages/checkout_confirmation/header_php.php creates $order = new order() which would run $order->cart() and only store the products_id in memory. It's not until checkout_process.php is run that $order->create_add_products is run and the products_name is ripped from zen_products_description straight into zen_order without being seen by the user.

It seems that when the the order is committed to the database, I could use NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM (per product in the order) or NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE_ADD_PRODUCTS (for post processing the whole order) to modify the product names in the order table. This would be a rather late stage, but would at least make the more specific name visible to our back office staff.

What would you recommend?

This may be related to this recent post, but I didn't want to jump in there if it's unrelated:
http://www.zen-cart.com/forum/showthread.php?t=182403

Thanks
Nick

30 Jun 2011, 7:20 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Does the notifier support changing Product Names as they go into the Cart, or Order?

Have you explored using the NOTIFIER_CART_GET_PRODUCTS_END notifier point?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.