News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Get cart data *before* it get's updated

Started by vmfyelloq19, March 07, 2022, 13:33:21 PM

Previous topic - Next topic

vmfyelloq19

Hi friends,

in my template override for cart/default.php I need to know what has changed when a customer updates cart items (quantity, remove item).
$this->cart is already updated with the news quantities, removed items are removed, $_POST only contains cart position ids ans quantities.

I need to display something like:
- Product #123 Foo's quantity has been updated from 1 to 3
- Product #444 Bar has been removed.

Any hints appreciated!

pinochico

Every action in cart use trigger (add to cart, remove from cart, change quantity) or equivalent in JS.

You can create system plugin for echo this trigger or custom JS fot the same.
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

vmfyelloq19

Thank you pinochico,

I cannot use JS for this. It needs to be done in PHP.

But for other tasks JS might be helpful. Mind providing examples how to intercept add/remove/upadte cart events with own JS?

Milbo

I think the best trigger for you is plgVmOnAddToCartFilter
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

vmfyelloq19

Milbo, thank you for your reply.

I was suspecting that I would need to go the plugin way...

So basically I will need maintain some sort of "shadow cart" keeping track of every add/remove/update event, and offer a way for the template to get this "cart before update"?

(Note to self: make sure this really is a robust solution even if customers use several tabs updating the cart from either of them.)

In case I write a plugin, I'll post it here.

pinochico

QuoteSo basically I will need maintain some sort of "shadow cart" keeping track of every add/remove/update event, and offer a way for the template to get this "cart before update"?

Why?

Now existing a lot of plugins with GA Enhanced Ecommerce, which make the same.
But go on :)
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

vmfyelloq19

Hi pinochico.

what exaclty is GA Enhanced Ecommerce and how does it help getting the required data in my template as described in the inital question?