pRieStaKos Posted November 22, 2020 Share Posted November 22, 2020 (edited) Hello, I want to change an addon price (Support Plan), when client chooses a specific configoption. I tried from OrderAddonPricingOverride and PreCalculateCartTotals from Shopping Cart, but neither of them worked. add_hook('OrderAddonPricingOverride', 1, function($vars) { $return = []; foreach($_SESSION['cart']['products'] as $product) { // This is a product with addon purchase $productObj = Product::find($product['pid']); if ($productObj->module == "OvhVpsAndDedicated") { foreach($product['configoptions'] as $id => $configOption) { $optionName = Capsule::table('tblproductconfigoptions')->where('id', $id)->value('optionName'); if ($optionName == "Storage") { $price = Capsule::table('tblpricing') ->where('type','configoptions') ->where('currency', 1) ->where('relid', $configOption) ->value('monthly'); $return = ['recurring' => $price['monthly'] * 1.20]; } } } } return $return; }); Any suggestions ? Thank you in advance. Edited November 22, 2020 by pRieStaKos 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted November 22, 2020 Share Posted November 22, 2020 Try using OrderProductPricingOverride instead as you're dealing with configurable options here and not addons and OrderAddonPricingOverride wont fire otherwise. I tested with OrderProductPricingOverride and it worked. Also I will presume you have the use capsule and product lines above this. 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted November 22, 2020 Author Share Posted November 22, 2020 12 minutes ago, steven99 said: Try using OrderProductPricingOverride instead as you're dealing with configurable options here and not addons and OrderAddonPricingOverride wont fire otherwise. I tested with OrderProductPricingOverride and it worked. Also I will presume you have the use capsule and product lines above this. Worked with $return = ['recurring' => $price * 1.20]; 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.