- Posts: 42
- Thank you received: 3
Additional Parameter in onBeforeCartSave
3 years 3 months ago - 3 years 3 months ago #353465
by JF
Additional Parameter in onBeforeCartSave was created by JF
-- 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,
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(&$element, &$do)
{
$additional = new stdClass();
$additional->name = 'package1';
$additional->price_currency_id = hikashop_getCurrency(); // this line is compulsary, else it wont change the total price
$additional->input_currency = $this->plugin_params->currencyid;
$additional->price_value = 10;
$additional->price_value_with_tax = -10;
$additional->current_total = 100;
$additional->discounted = 10;
$element->cart_params->additional1 = $additional;
foreach($element->cart_params as $param)
{
$additional = new stdClass();
$additional->name = $param->name;
$additional->price_currency_id = $param->price_currency_id;
$additional->input_currency = $param->input_currency;
$additional->price_value = -$param->discounted;
$additional->price_value_with_tax = -$param->discounted;
$element->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);
}
Last edit: 3 years 3 months ago by nicolas.
Please Log in or Create an account to join the conversation.
3 years 3 months ago #353476
by nicolas
Replied by nicolas on topic Additional Parameter in onBeforeCartSave
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
Its goal is precisely to add an additional fee to carts.
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
Its goal is precisely to add an additional fee to carts.
Please Log in or Create an account to join the conversation.
Time to create page: 0.127 seconds