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

#   Additional Parameter in 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
-
-

3 years 4 months ago -  3 years 4 months ago [\#353465](#353465) by [JF](/forum/user/67343-jf "View JF's Profile")  *[Additional Parameter in onBeforeCartSave](/forum/25-install-update/906731-additional-parameter-in-onbeforecartsave#353465 "-- url of the page with the problem -- :   lazykitchen.satumalaysiahosting.com/checkout?package=1  Hi,  I would like to show package discount in checkout page using onBeforeCartSave method.  But seems like the discount won't show up even the additional already saved.  May I know the reason or the correct way to implement this?  Thanks.  -----  -----")* was created by *[JF](/forum/user/67343-jf "View JF's Profile")*

-- url of the page with the problem -- : [ lazykitchen.satumalaysiahosting.com/checkout?package=1](https://lazykitchen.satumalaysiahosting.com/checkout?package=1)

Hi,

I would like to show package discount in checkout page using onBeforeCartSave method.

But seems like the discount won't show up even the additional already saved.

May I know the reason or the correct way to implement this?

Thanks.

---

Code:

function onBeforeCartSave(&amp;$element, &amp;$do) { $additional = new stdClass(); $additional-&gt;name = 'package1'; $additional-&gt;price_currency_id = hikashop_getCurrency(); // this line is compulsary, else it wont change the total price $additional-&gt;input_currency = $this-&gt;plugin_params-&gt;currencyid; $additional-&gt;price_value = 10; $additional-&gt;price_value_with_tax = -10; $additional-&gt;current_total = 100; $additional-&gt;discounted = 10; $element-&gt;cart_params-&gt;additional1 = $additional; foreach($element-&gt;cart_params as $param) { $additional = new stdClass(); $additional-&gt;name = $param-&gt;name; $additional-&gt;price_currency_id = $param-&gt;price_currency_id; $additional-&gt;input_currency = $param-&gt;input_currency; $additional-&gt;price_value = -$param-&gt;discounted; $additional-&gt;price_value_with_tax = -$param-&gt;discounted; $element-&gt;additional['package1'] = $additional; } $fp = fopen('params.txt', 'w'); fwrite($fp, print_r($element, TRUE)); fclose($fp); $fp = fopen('addi.txt', 'w'); fwrite($fp, print_r($previous_total, TRUE)); fclose($fp); }

---

- [ ![Capture&#95;2023-07-18.PNG](/forum/attachment/57401) ](/forum/attachment/57401 "...2023-07-18.PNG") [ ](/forum/attachment/57401?download=1 "...2023-07-18.PNG")
- [ ![Capture2&#95;2023-07-18.PNG](/forum/attachment/57402) ](/forum/attachment/57402 "...2023-07-18.PNG") [ ](/forum/attachment/57402?download=1 "...2023-07-18.PNG")

Last edit: 3 years 4 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzkwNjczMS1hZGRpdGlvbmFsLXBhcmFtZXRlci1pbi1vbmJlZm9yZWNhcnRzYXZlP3RtcGw9bWFya2Rvd24=) 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
-
-

3 years 4 months ago [\#353476](#353476) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Additional Parameter in onBeforeCartSave](/forum/25-install-update/906731-additional-parameter-in-onbeforecartsave#353476 "-- url of the page with the problem -- :   lazykitchen.satumalaysiahosting.com/checkout?package=1  Hi,  I would like to show package discount in checkout page using onBeforeCartSave method.  But seems like the discount won't show up even the additional already saved.  May I know the reason or the correct way to implement this?  Thanks.  -----  -----")*

Hi,

Additionals are to be added on the fly when the cart is being loaded.
I would recommend to look at the code of this plugin:
[ www.hikashop.com/marketplace/product/224-global-cart-fee.html](https://www.hikashop.com/marketplace/product/224-global-cart-fee.html)
Its goal is precisely to add an additional fee to carts.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzkwNjczMS1hZGRpdGlvbmFsLXBhcmFtZXRlci1pbi1vbmJlZm9yZWNhcnRzYXZlP3RtcGw9bWFya2Rvd24=) 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.062 seconds

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