Add mass products with one button

  • Posts: 42
  • Thank you received: 3
1 year 7 months ago #343912

-- url of the page with the problem -- : eduquay.satumalaysiahosting.com/bundle-p...74-b-buku-buku-tulis

URL: eduquay.satumalaysiahosting.com/bundle-p...74-b-buku-buku-tulis

I have created an 'Add All' button to add all the listing products to the cart, the method I'm using now is triggered the 'href' by JQuery, but it seems too heavy for the server.

Any Idea?

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 42
  • Thank you received: 3
1 year 7 months ago #343917

Already created a plug-in but not sure what to do with it..

$cartClass = hikashop_get('class.cart');
$do=true;
JPluginHelper::importPlugin('add_all_to_cart');
$dispatcher=JDispatcher::getInstance();
$dispatcher->trigger('onBeforeCartSave', array(&$cartClass ,&$do));



function onBeforeCartSave(&$element,&$do)
{
// Code

}

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
1 year 7 months ago #343914

Hi,

If you set the "Add to cart on listings" setting to "global" under the Display tab of the HikaShop configuration, you'll automatically have a global add to cart button on the listing instead of one per product.

With that setting set to "one per product", you have to do it like you're doing, but then, it means that the javascript is sending one add to cart request for each product so that's a lot at once. A better solution would be to have more complex javascript to load the quantity of each product on the listing and manually construct the URL of the AJAX request (to get similar data to what the global add to cart button does) so that there is only one AJAX request. So that's possible, but it's several hours of javascript development.

Please Log in or Create an account to join the conversation.

Time to create page: 0.059 seconds
Powered by Kunena Forum