-- url of the page with the problem -- :
benwijn-d-o-t-nl.alvast-online.nl
-- HikaShop version -- : 4.0.1
-- Joomla version -- : 3.9.1
-- PHP version -- : 7.2.10
-- Browser(s) name and version -- : Chrome
-- Error-message(debug-mod must be tuned on) -- : None
Hi there,
I'm trying to make a hikashop plugin for 11the bottle for free in my shop.
I've succeeded in adapting the price with a plugin, but the subtotal and the total in the cart are not changing on 12th product.
I think i need function onBeforeCartSave(&$element,&$do) to do this. Do you have a documentation about the $element?
I don't know how to adress the product price in this element.
Or do i have to make a change in the subtotal/total calculation? I so, what file do i have to adapt?
Thx
My plugin for now:
<?php
defined('_JEXEC') or die;
?><?php
class plgHikashopTwelveforeleven extends JPlugin {
function plgTwelveforeleven(&$subject, $config){
parent::__construct($subject, $config);
}
//function onBeforeCartSave(&$element,&$do) {
//$lst1 = $element->cart_products;
//foreach ($lst1 as $item) {
//if ($item->cart_product_total_quantity == 12) {
//$element=null;
//$item->prices[0]->price_value_with_tax = 1 * $item->prices[0]->price_product_id;
//}
//}
//}
function onAfterCartProductsLoad(&$cart) {
$lst1 = $cart->products;
//echo"<pre>";var_dump($lst1);
foreach ($lst1 as $item) {
if ($item->cart_product_total_quantity == 12) {
$item->prices[0]->price_value_with_tax = 11 * $item->prices[0]->price_id;
}
}
}
}
Krgds, Matthieu