Nickovitshj Posted February 23, 2022 Share Posted February 23, 2022 (edited) Hi there, What I want to achieve: I want my voucher information to be showed on any .tpl file. For example on a product.tpl file, or on the homepage of my store. From what I understand the cart rule logic is to be found in: /controllers/front/DiscountController.php And if I want to make it accessible anywhere I should add it to the array found in the following function: protected function assignGeneralPurposeVariables() In file: /classes/controller/FrontController.php Basically I want to put the contect from the discount.tpl file in other .tpl files: /themes/classic/templates/customer/discount.tpl However, I find myself not being able to manage this. Is there anyone with more experience in this who can help me with this? PS version: 1.7.6.5 Edited February 28, 2022 by Nickovitshj (see edit history) Link to comment Share on other sites More sharing options...
Nickovitshj Posted February 23, 2022 Author Share Posted February 23, 2022 I have now added the following variable to the following code: protected function assignGeneralPurposeVariables() In file: /classes/controller/FrontController.php Added code: 'cart_ruleseverywhere4' => CartRule::getCustomerCartRules( $this->context->language->id, (isset($this->context->customer->id) ? $this->context->customer->id : 0), true, true, true, $this->context->cart), The result is that I'm now only getting the CODE, DESCRIPTION AND QUANTITY. But I need the other fields as well, which are: Value, Minimum, Cumulative, Expiration date However, these are not showing.... Link to comment Share on other sites More sharing options...
Nickovitshj Posted February 23, 2022 Author Share Posted February 23, 2022 Solution found: The code that I had added above is good to use. It seems that in my .tpl file my foreach loop that I had copied from discount.tpl could not be used in my new .tpl file. I had to change the following: {$cart_rule.value} to {$cart_rule.reduction_amount} {$cart_rule.voucher_date} to {$cart_rule.date_to} Original code: {if $cart_ruleseverywhere4} <table class="table table-striped table-bordered hidden-sm-down"> <thead class="thead-default"> <tr> <th>{l s='Code' d='Shop.Theme.Checkout'}</th> <th>{l s='Description' d='Shop.Theme.Checkout'}</th> <th>{l s='Quantity' d='Shop.Theme.Checkout'}</th> <th>{l s='Value' d='Shop.Theme.Checkout'}</th> <th>{l s='Expiration date' d='Shop.Theme.Checkout'}</th> </tr> </thead> {foreach from=$cart_ruleseverywhere4 item=cart_rule} <table class="table table-striped table-bordered hidden-sm-down"> <tbody> <tr> <th scope="row">{$cart_rule.code}</th> <td>{$cart_rule.name}</td> <td class="text-xs-right">{$cart_rule.quantity_for_user}</td> <td>{$cart_rule.amount} (Tax Incl.)</td> <td>{$cart_rule.voucher_date}</td> </tr> {/foreach} </tbody> </table> {/if} Edited code: {if $cart_ruleseverywhere4} <table class="table table-striped table-bordered hidden-sm-down"> <thead class="thead-default"> <tr> <th>{l s='Code' d='Shop.Theme.Checkout'}</th> <th>{l s='Description' d='Shop.Theme.Checkout'}</th> <th>{l s='Quantity' d='Shop.Theme.Checkout'}</th> <th>{l s='Value' d='Shop.Theme.Checkout'}</th> <th>{l s='Expiration date' d='Shop.Theme.Checkout'}</th> </tr> </thead> {foreach from=$cart_ruleseverywhere4 item=cart_rule} <table class="table table-striped table-bordered hidden-sm-down"> <tbody> <tr> <th scope="row">{$cart_rule.code}</th> <td>{$cart_rule.name}</td> <td class="text-xs-right">{$cart_rule.quantity_for_user}</td> <td>{$cart_rule.reduction_amount} (Tax Incl.)</td> <td>{$cart_rule.date_to}</td> </tr> {/foreach} </tbody> </table> {/if} Hope this helps people in the future Link to comment Share on other sites More sharing options...
Nickovitshj Posted February 23, 2022 Author Share Posted February 23, 2022 If anyone has any idea, as to how I can make a sum of the {$cart_rule.reduction_amount} values, I'd love to hear that. I'd like to show that as well in my .tpl file. Link to comment Share on other sites More sharing options...
Nickovitshj Posted February 28, 2022 Author Share Posted February 28, 2022 In the meantime I have found a solution for my question above. The current result can be found in the image I uploaded. Now I want to show information for the category restrictions that are being set for these vouchers. However, currently the only information I can get is a 1 or a 0. {if $cart_rule.product_restriction == 0}Voucher can be used for all products{/if} But when my $cart_rule.product_restriction == 1 I should be able to list the category or multiple categories that this cart rule has been restricted to. However, currently I'm clueless as to how I can achieve this. I tried looking up how to possibly achieve this through an SQL query. But the tables that are used for this are so incredibly unclear. Result is that I can't even find the category name or id's being linked to these cart rules. Thanks in advance, Nick Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now