News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

(FIXED)After UPGRADE to 3.4.2 Product Quantity Plugin No Longer Changing Price

Started by PRO, November 02, 2018, 02:46:55 AM

Previous topic - Next topic

PRO

updated, fixed solution at the bottom
Trying to get my last product plugin working on 3.4.2
It modifies the product weight, and also the product price.
In 3.4.2 The weight is still modified by the plugin, but the new price is not.

Tried it on a few different configurations.
J 3.8.3  V 3.4.2, php 7.2.10
and PHP 7.0.32   J3.8.3    V3.4.2
and J 3.8.3 , PHP 7.0.32 V3.4.2
also tried with vmbeez :)

Is there a new method that needs to be used?

//Prepare Cart
   public function plgVmPrepareCartProduct(&$product, &$customfield,$selected,&$modificatorSum = 0){
      if ($customfield->custom_element !==$this->_name) return;
   if (!empty($customfield->under_disc)){
   if ($product->quantity <= $customfield->under_disc){$product->product_weight=$customfield->under_discmod;}
   }
   if (!empty($customfield->modifier)){
   if ($product->quantity>=$customfield->modifier){$product->product_weight=0;}
   }
   if (!empty($customfield->disc)){
   if ($product->quantity >=$customfield->disc && $product->quantity <$customfield->modifier){$product->product_weight=$customfield->discmod;}
   }
   // return prices
   $product->allPrices[$product->selectedPrice]["product_price"]= $this->applyDiscount($customfield->qdisc1,$customfield->qdisc2,$customfield->qdisc3,$product->quantity,$product->allPrices[$product->selectedPrice]["product_price"]);
      return true;
      //vmdebug('plgVmPrepareCartProduct we can modify the product here');

   }


fixed by returning $modificatorSum  instead of changing price via $product->allPrices[$product->selectedPrice]["product_price"]

   //Prepare Cart
   public function plgVmPrepareCartProduct(&$product, &$customfield,$selected,&$modificatorSum = 0){
      if ($customfield->custom_element !==$this->_name) return;
   if (!empty($customfield->under_disc)){
   if ($product->quantity <= $customfield->under_disc){$product->product_weight=$customfield->under_discmod;}
   }
   if (!empty($customfield->modifier)){
   if ($product->quantity>=$customfield->modifier){$product->product_weight=0;}
   }
   if (!empty($customfield->disc)){
   if ($product->quantity >=$customfield->disc && $product->quantity <$customfield->modifier){$product->product_weight=$customfield->discmod;}
   }
   // return prices

   $modificatorSum = $this->applyDiscount($customfield->qdisc1,$customfield->qdisc2,$customfield->qdisc3,$product->quantity,$product->allPrices[$product->selectedPrice]["product_price"])-$product->allPrices[$product->selectedPrice]["product_price"];
   
      return ;
      //vmdebug('plgVmPrepareCartProduct we can modify the product here');

   }