robycrazy Posted April 8, 2016 Share Posted April 8, 2016 Hello everyone, I have attribute that change the price of some products for 1, 2 or 3 packs! (example : the basic price is 26 € for 1 pakc, for 2 pakcs there is attribute with 2 € less. i.e. 50 € for 2 pakcs ) I create customer group with discount - these products which has this attribute change their prices inproper .. 10 % form 26 is 23.40 - but there has still other price lower!!! can somebody to help me to insert a condition in product.tpl when a customer of this group login to view the correct amount of the discount (only 23.40)! for <p class="our_price_display" itemprop="offers" itemscope="" itemtype="http://schema.org/Offer"><link itemprop="availability" href="http://schema.org/InStock"> <span id="our_price_display" itemprop="price"> something like {if $checkcustomer->id_default_group== '4'} style="display:none;"{/if} and something to remove strikethrough from the proper price in that condition! Link to comment Share on other sites More sharing options...
shokinro Posted April 9, 2016 Share Posted April 9, 2016 first you will need to prepare the smarty variable so that you can use in theme file. for product page, you will need to prepare it in ProductController.php //get All groups of current customer $groups = $this->context->customer->getGroups(); //Then check the group if the customer your sepcific group, then set following variable to true $isCustomerInSpecificGroups = 1; // 1 or 0 based on your conditions $this->context->smarty->assign(array('isCustomerInSpecificGroups' => $isCustomerInSpecificGroups)); After that you can use the smarty variable in product.tpl {if isset($isCustomerInSpecificGroups) && $isCustomerInSpecificGroups == 1} your price display here {/if} Link to comment Share on other sites More sharing options...
robycrazy Posted April 9, 2016 Author Share Posted April 9, 2016 Hi shokinro, thanks for your reply .. I added what you wrote in ProductController.php right after: * Assign price and tax to the template * / protected function assignPriceAndTax () { then in Produtst. tpl I put condition: <div class="price"> <p class="our_price_display" itemprop="offers" itemscope itemtype="http://schema.org/Offer"> {if $product->quantity > 0}<link itemprop="availability" href="http://schema.org/InStock"/>{/if} {if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display" itemprop="price">{convertPrice price=$productPrice}</span> <!--{if $tax_enabled && ((isset($display_tax_label) && $display_tax_label == 1) || !isset($display_tax_label))} {if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if} {/if}--> {if isset($isCustomerInSpecificGroups) && $isCustomerInSpecificGroups == 4} <span id="our_price_display" itemprop="price">{convertPrice price=$productPriceWithoutReduction}</span> {/if} <meta itemprop="priceCurrency" content="{$currency->iso_code}" /> {/if} </p> But it seems the condition is not running ... I get the following: i try couple of hours but can not figured out ... and decided to ask If I'm not mistaken somewhere or something !? Link to comment Share on other sites More sharing options...
shokinro Posted April 9, 2016 Share Posted April 9, 2016 I think there should be multiple price displaying sections in product.tpl file, I guess you might be are editing the wrong section of the theme file, please try to output some contents without conditions for example following one, and see if it is showing up, otherwise you are editing the wrong place or wrong file. ?????????????? { $isCustomerInSpecificGroups} First make sure you are editing correct place Link to comment Share on other sites More sharing options...
robycrazy Posted April 9, 2016 Author Share Posted April 9, 2016 (edited) I insert in ProductController.php right after: * Assign price and tax to the template * / protected function assignPriceAndTax () { $groups = $this->context->customer->getGroups(); $isCustomerInSpecificGroups == 4; //my customer group $this->context->smarty->assign(array('isCustomerInSpecificGroups' => $isCustomerInSpecificGroups)); But it does not work when inserted in Product.tpl ... yes it has multiple price displaying sections, but the section which i need is: <!-- prices --> <div class="price"> <p class="our_price_display" itemprop="offers" itemscope itemtype="http://schema.org/Offer"> {if $product->quantity > 0}<link itemprop="availability" href="http://schema.org/InStock"/>{/if} {if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display" itemprop="price" >{convertPrice price=$productPrice}</span> <!--{if $tax_enabled && ((isset($display_tax_label) && $display_tax_label == 1) || !isset($display_tax_label))} {if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if} {/if}--> I tried another way .. I insert in ProductController.php : $this->context->smarty->assign('checkcustomer',$this->context->customer); then I changed : <div class="price"> <p class="our_price_display" itemprop="offers" itemscope itemtype="http://schema.org/Offer"> {if $product->quantity > 0}<link itemprop="availability" href="http://schema.org/InStock"/>{/if} {if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display" itemprop="price" {if $checkcustomer->id_default_group == 4} style="display: none;"{/if}>{convertPrice price=$productPrice}</span> <!--{if $tax_enabled && ((isset($display_tax_label) && $display_tax_label == 1) || !isset($display_tax_label))} {if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if} {/if}--> {if $checkcustomer->id_default_group == 4} <span id="our_price_display" itemprop="price" >{convertPrice price=$productPriceWithoutReduction}</span> {/if} it's work at half .. it is ok with customer group different from 4,.. but in group 4 the price does not change when you select attribute with a different price! Only change the bottom price : <p id="old_price"> <span id="old_price_display">23,40 €</span></p> which come from line 256 in Product.tpl Any idea !??! Edited April 9, 2016 by robycrazy (see edit history) Link to comment Share on other sites More sharing options...
robycrazy Posted April 11, 2016 Author Share Posted April 11, 2016 Can anyone help me please !!! Link to comment Share on other sites More sharing options...
shokinro Posted April 11, 2016 Share Posted April 11, 2016 If it is a product with different attribute combination, then you will also need implement something in JavaScript to change it dynically when user change attribute. The change above you have done only works for initial attributte. Link to comment Share on other sites More sharing options...
robycrazy Posted April 11, 2016 Author Share Posted April 11, 2016 I do not know why there is such problem in cool platform like presta... If you have a product that has various additions it is normal the price to be change also!!! How to do this with javascript .. i dont know.. can you help me! Who file and what values i must to change !!? Nevertheless, Shokinro I thank you for your attention so far! Link to comment Share on other sites More sharing options...
shokinro Posted April 12, 2016 Share Posted April 12, 2016 The price of product with attribute combination usually is different for different combination, so user is able to choose different combination and the price should be changed dynamically based on user selection/choices. this dynamic price change is done thought javascript, it is not a simple one like simple product. If this feature is very import, I suggest you try to hire someone to help if you are not able to handle by yourself, I am sorry it is difficult to give further detailed instructions, Link to comment Share on other sites More sharing options...
robycrazy Posted April 12, 2016 Author Share Posted April 12, 2016 I tested a new local installation 1.6.1.4 .. turned out that everything is fine .. The problem is that when I upgraded shop version to 1.6.1.4 my theme remained unchanged .. which files i must to overwrite to fix my problem !?! HELP... pls Link to comment Share on other sites More sharing options...
shokinro Posted April 13, 2016 Share Posted April 13, 2016 Without comparing the database data (record) between the one works normal and then one does not work, it is difficult to find out imgine what is the cause. As I mentioned multiple time previous, the only way to find out is to compare the data in database. I do not have any other better idea, unless you debug the PrestaShop system. 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