- Posts: 42
- Thank you received: 3
Add mass products with one button
4 years 1 month ago #343912
by JF
Add mass products with one button was created by JF
-- 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?
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?
Please Log in or Create an account to join the conversation.
4 years 1 month ago #343917
by JF
Replied by JF on topic Add mass products with one button
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
}
$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.
4 years 1 month ago #343914
by nicolas
Replied by nicolas on topic Add mass products with one button
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.
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.174 seconds