pRieStaKos Posted December 15, 2020 Share Posted December 15, 2020 (edited) Hello, I'm trying to recalculate the Order Summary and set the product price, to each billing cycle by multiplying monthly price. Monthly = $350 USD Quarterly = Monthly * 3 Semi-Annually = Monthly * 6 Annually = Monthly * 12 .... The product got $0.00 USD Price and the total is been calculated by available Config Options. {if $cycle eq "Monthly"} {assign var="oldMonthlyRecurring" value=" "|explode:$recurring} {assign var="MonthlyRecurring" scope="global" value=($oldMonthlyRecurring[0]|replace:{$currency.prefix}:'')|round:2} <div class="clearfix"> <span class="pull-left">{$cycle}:</span> {* <span class="pull-right">{$recurring}</span> *} <span class="pull-right">{$currency.prefix}{$MonthlyRecurring} {$currency.suffix}</span> </div> {elseif $cycle eq "Quarterly"} <div class="clearfix"> <span class="pull-left">{$cycle}:</span> {assign var="QuarterlyRecurring" value=($MonthlyRecurring * 3)|round:2} <span class="pull-right">{$currency.prefix}{$QuarterlyRecurring} {$currency.suffix}</span> </div> {/if} I'm trying to assign the monthly price as global smarty var on `ordersummary.tpl`, but it returns 0. Any suggestions ? Edited December 15, 2020 by pRieStaKos 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted December 15, 2020 Share Posted December 15, 2020 Is there a reason you are not using the built-in config options to do that? In the quarterly if, you are trying to use MonthlyRecurring but that was set / assigned in the monthly if . Move the assignment out of the if block and that should help. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 15, 2020 Share Posted December 15, 2020 is there a reason for trying to do like this rather than just using pricing the config options with those multiples directly in the pricing setup ? 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted December 15, 2020 Author Share Posted December 15, 2020 (edited) 2 hours ago, steven99 said: Is there a reason you are not using the built-in config options to do that? In the quarterly if, you are trying to use MonthlyRecurring but that was set / assigned in the monthly if . Move the assignment out of the if block and that should help. 1 hour ago, brian! said: is there a reason for trying to do like this rather than just using pricing the config options with those multiples directly in the pricing setup ? There is always "a reason" guys.....That's what makes our live more difficult. 😄 I created a hook to get all (sum) the configoption monthly prices and return it to a template var, so I can set the ordersummary.tpl to recalculate the billing cycle price. add_hook('OrderProductPricingOverride', 1, function($vars) { global $smarty; $totalMonthly = 0; $productGroups = ['Product Group 1', 'Product Group 3', 'Product Group 5']; $productObj = Product::find($vars['pid']); if (in_array($productObj->productGroup['name'], $productGroups)) { foreach ($vars['proddata']['configoptions'] as $configoption) { $price = Capsule::table('tblpricing')->where('type', 'configoptions')->where('currency', 1)->where('relid', $configoption)->value('monthly'); $totalMonthly += $price; } } $smarty->assign('monthlyRecurringPrice', $totalMonthly); }); The goal is to make the Order Summary show the Starting Product Price with strike and return the Discounted (actual) Price the client gets and see what he "saves" on other billing cycles. @brian! its a modified request of an old topic you had with discount labels (attached). Edited December 15, 2020 by pRieStaKos 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted December 15, 2020 Share Posted December 15, 2020 You may want to check out this thread that discussing something similar: Though I don't think that deals with config options. However, I think you would best off using an output hook with jquery to get this done as discussed in that thread. 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted December 15, 2020 Author Share Posted December 15, 2020 5 minutes ago, steven99 said: You may want to check out this thread that discussing something similar: Though I don't think that deals with config options. However, I think you would best off using an output hook with jquery to get this done as discussed in that thread. I don’t want to add this in the billing cycle drop list or make it an alert. The goal was to add it in the Order Summary with all the correct calculations and it’s already done with the hook plus tpl changes for calculations. Thank you all 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted December 15, 2020 Share Posted December 15, 2020 I was giving an example of how something similar was being done so that you could take that and change it to your needs. As you're using a hook already, it is best to use an output hook and use jquery / javascript to inject such changes rather then changing the template. Also, in your hook you assign monthlyRecurringPrice but in the template you use MonthlyRecurring and in at least the quarterly that would matter. 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted December 15, 2020 Author Share Posted December 15, 2020 I changed the template code. All good Thank you for your replies. 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.