[Skip to main content](#vessel-content)

#   onBeforeCartSave

##

- **[JF](/forum/user/67343-jf "View JF's Profile")**
- [![JF's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/67343-jf "View JF's Profile") Topic Author
- [ Offline](/forum/user/67343-jf)

Less More

- Posts: 42
- Thank you received: 3
-
-

4 years 4 months ago [\#343398](#343398) by [JF](/forum/user/67343-jf "View JF's Profile")  *[onBeforeCartSave](/forum/27-checkout/904764-onbeforecartsave#343398 "-- url of the page with the problem -- :   eduquay.satumalaysiahosting.com/bundle-p...8-buku-buku-lembaran  I'm trying to save all bundled products with one click hence I developed a plugin implementing onBeforeCartSave.  But I'm confused about the function body for example, what should I write in the plug-in function.  ----- function onBeforeCartSave(&amp;$element,&amp;$do) { // Code } -----  I have already gone through the documentation but still have no idea. I hope can get some examples here.")* was created by *[JF](/forum/user/67343-jf "View JF's Profile")*

-- url of the page with the problem -- : [ eduquay.satumalaysiahosting.com/bundle-p...8-buku-buku-lembaran](https://eduquay.satumalaysiahosting.com/bundle-product/category/68-buku-buku-lembaran)

I'm trying to save all bundled products with one click hence I developed a plugin implementing onBeforeCartSave.

But I'm confused about the function body for example, what should I write in the plug-in function.

---

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

---

I have already gone through the documentation but still have no idea. I hope can get some examples here.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwNDc2NC1vbmJlZm9yZWNhcnRzYXZlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14327
-
-

4 years 4 months ago [\#343400](#343400) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[onBeforeCartSave](/forum/27-checkout/904764-onbeforecartsave#343400 "-- url of the page with the problem -- :   eduquay.satumalaysiahosting.com/bundle-p...8-buku-buku-lembaran  I'm trying to save all bundled products with one click hence I developed a plugin implementing onBeforeCartSave.  But I'm confused about the function body for example, what should I write in the plug-in function.  ----- function onBeforeCartSave(&amp;$element,&amp;$do) { // Code } -----  I have already gone through the documentation but still have no idea. I hope can get some examples here.")*

Hi,

What do you mean by "save all bundled products with one click" ?
The onBeforeCartSave event is triggered when the cart of the user is modified (when a product is added, removed, updated, etc).

Are you saying that when a product is added to the cart, you want to also add to it the bundled products of that product to the cart ?
You'll find the products in $element-&gt;products
So you'll first want to loop on the products in there, and load the bundled products of these products with a MySQL query on the hikashop_product_related table. You'll then want to add them to $element-&gt;products.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwNDc2NC1vbmJlZm9yZWNhcnRzYXZlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[JF](/forum/user/67343-jf "View JF's Profile")**
- [![JF's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/67343-jf "View JF's Profile") Topic Author
- [ Offline](/forum/user/67343-jf)

Less More

- Posts: 42
- Thank you received: 3
-
-

4 years 4 months ago [\#343426](#343426) by [JF](/forum/user/67343-jf "View JF's Profile")  Replied by *[JF](/forum/user/67343-jf "View JF's Profile")* on topic *[onBeforeCartSave](/forum/27-checkout/904764-onbeforecartsave#343426 "-- url of the page with the problem -- :   eduquay.satumalaysiahosting.com/bundle-p...8-buku-buku-lembaran  I'm trying to save all bundled products with one click hence I developed a plugin implementing onBeforeCartSave.  But I'm confused about the function body for example, what should I write in the plug-in function.  ----- function onBeforeCartSave(&amp;$element,&amp;$do) { // Code } -----  I have already gone through the documentation but still have no idea. I hope can get some examples here.")*

Hi,

URL: [ eduquay.satumalaysiahosting.com/bundle-p...8-buku-buku-lembaran](https://eduquay.satumalaysiahosting.com/bundle-product/category/68-buku-buku-lembaran)

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.

So I'm now trying to develop a plugin to perform this action.

- [ ![Capture&#95;2022-07-22.PNG](/forum/attachment/55303) ](/forum/attachment/55303 "...2022-07-22.PNG") [ ](/forum/attachment/55303?download=1 "...2022-07-22.PNG")

The following user(s) said Thank You: [Philip](/forum/user/34318-philip "View Philip's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwNDc2NC1vbmJlZm9yZWNhcnRzYXZlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Philip](/forum/user/34318-philip "View Philip's Profile")**
- [![Philip's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/34318-philip "View Philip's Profile")
- [ Offline](/forum/user/34318-philip)

Less More

- Posts: 4820
- Thank you received: 652
-
-

4 years 4 months ago [\#343432](#343432) by [Philip](/forum/user/34318-philip "View Philip's Profile")  Replied by *[Philip](/forum/user/34318-philip "View Philip's Profile")* on topic *[onBeforeCartSave](/forum/27-checkout/904764-onbeforecartsave#343432 "-- url of the page with the problem -- :   eduquay.satumalaysiahosting.com/bundle-p...8-buku-buku-lembaran  I'm trying to save all bundled products with one click hence I developed a plugin implementing onBeforeCartSave.  But I'm confused about the function body for example, what should I write in the plug-in function.  ----- function onBeforeCartSave(&amp;$element,&amp;$do) { // Code } -----  I have already gone through the documentation but still have no idea. I hope can get some examples here.")*

Hello,

This message just to inform you that we are in reduced numbers (holiday period), and that consequently our follow-up will be slower than usual.
Hope this is not a problem for you

Regards

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwNDc2NC1vbmJlZm9yZWNhcnRzYXZlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.063 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
