Hi
I solved almost all the problems ...
Delete a product:
public function onBeforeCartUpdate(&$cartClass,&$cart,$product_id,$quantity,$add,$type,$resetCartWhenUpdate,$force) {
...
$cartClass->updateEntry(0,$cartContent,(int)$product->cart_product_id,0,false,'item',$force);
...
}
Add a product:
public function onAfterCartUpdate(&$cartClass,&$cart,$product_id,$quantity,$add,$type,$resetCartWhenUpdate,$force) {
...
$cartClass->mainProduct = null;
$cartClass->updateEntry('1',$cartContent,(int)$product->field_vorbereitung,'1',false,'product',$force);
...
}
I have this code to change the price of a product. But so calculated prices will not be applied in the Shopping Cart. Why and what can I do?
---
public function onBeforeCartUpdate(&$cartClass,&$cart,$product_id,$quantity,$add,$type,$resetCartWhenUpdate,$force) {
$price_factor = 1.0;
$cartContent = $cartClass->get();
$c = $cartClass->loadFullCart();
if ( count($c->products) ) {
foreach($c->products as $product) {
if (!empty($product->field_must_be_engraved)) {
$price_factor = (float)$product->field_preis_faktor;
} else if (empty($product->field_forced)) {
$product->prices[0]->unit_price->price_value *= $price_factor;
$product->prices[0]->unit_price->price_value_with_tax *= $price_factor;
$product->prices[0]->price_value *= $price_factor;
$product->prices[0]->price_value_with_tax *= $price_factor;
...
}
---