Customisation not applied when changing Varient

  • Posts: 41
  • Thank you received: 2
7 years 9 months ago #282391

-- HikaShop version -- : 3.2.0
-- Joomla version -- : 3.8.2
-- PHP version -- : 7.1.11
-- Browser(s) name and version -- : all

I have customised the display so some categories don't display the VAT amount, this works correctly when the product is displayed. When the variant is changed however it ignores the customised display.

Is there another file I need to override in order to achieve this? or is it possible in a future release the ability to display prices including VAT or excluding VAT can be set at the category level?

Regards,
Dave

Please Log in or Create an account to join the conversation.

  • Posts: 84237
  • Thank you received: 13680
  • MODERATOR
7 years 9 months ago #282402

Hi,

If you've done your change in the "listing_price" file of the "product" view, the change should appear for both the default and the variant prices, unless there is a problem with the code change you added there.
If you've done the change in the "show_default" file of the "product" view, then the variants won't be affected and you also need to make a similar change in the "show" file of the "product" view where the variant data is output.

We don't plan on adding a with/without taxes setting on a per category basis. It is too specific and almost no one would use it. However, with some customization it's possible to achieve it.

Please Log in or Create an account to join the conversation.

  • Posts: 41
  • Thank you received: 2
7 years 9 months ago #282464

Hi Nicolas,

I have double checked this evening the process that I used which is:
I copied the product / show_ to create a new file product / show_inc_vat.php
I then edited the link to the prices to product / listing_inc_vat.php from product / listing_price.php
I have made all my edits to the product / listing_inc_vat.php file

I have attached my listing_inc_vat.php file and for reference price with tax = 2 in options

I just copied my edit and pasted it over the default product / listing when this is in place it works as expected, however, I need to display some products with VAT and others without VAT and all of them have variants.
This says to me that the variants aren't following the custom file but reverting to the standard version. How do I stop this behavior? I would expect the variants to follow the display file that's selected in the product options.

File Attachment:

File Name: listing_inc_vat.txt
File Size:10 KB


BTW on the default product / listing_price.php lines 12 - 14 are duplicated at lines 15 - 19 this is on the latest release

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 84237
  • Thank you received: 13680
  • MODERATOR
7 years 9 months ago #282503

Hi,

Well, as I said, the issue is that you've modified show_inc_vat.php to use listing_inc_vat, but you didn't change the "show" view file to also use listing_inc_vat.
As I said in my previous message, if you customize the display of the price in show_default.php (or the other show_ you're using) you also need to do a similar change in show.php

Please Log in or Create an account to join the conversation.

  • Posts: 41
  • Thank you received: 2
7 years 9 months ago #282542

Hi,

So editing the 'show.php' file has a global effect which can't be overridden for certain views?

The requirement I have is some products are business to business which the clients don't want VAT showing, other products are to the general public which expect to see the VAT amount. Up till this point the overrides appeared simple and intuitive.

from show.php is the following is it possible to change the if statements to take the required listing_ file dependant on what is set on the Product - Display - Page Layout section?

201	<div id="hikashop_product_price_<?php echo $variant_name; ?>" style="display:none;"><?php
202		if((int)$this->params->get('show_price', -1) == -1) {
203			$this->params->set('show_price', (int)$this->config->get('show_price'));
204		}
205		if ($this->params->get('show_price')) {
206			$this->setLayout('listing_inc_vat');
207			echo $this->loadTemplate();
208		}
209	?></div>

Please Log in or Create an account to join the conversation.

  • Posts: 84237
  • Thank you received: 13680
  • MODERATOR
7 years 9 months ago #282569

Hi,

As you said, in that case, you need to have an if/else in the show.php file to load either the listing_inc_vat or the listing_price based on the value of the layout configured in the product. You can find that value in the variable $this->element->main->product_layout

Please Log in or Create an account to join the conversation.

  • Posts: 41
  • Thank you received: 2
7 years 9 months ago #282691

Hi Nicolas,

Thanks for your help so far, having read the code I thought the below would have worked, can you correct the error in my logic please :)

	<div id="hikashop_product_price_<?php echo $variant_name; ?>" style="display:none;"><?php
		if((int)$this->params->get('show_price', -1) == -1) {
			$this->params->set('show_price', (int)$this->config->get('show_price'));
		}
        if ($this->params->get('show_price')) {
            if ($this->element->main->product_layout('show_inc_vat')){
              $this->setLayout('listing_inc_vat');
                echo $this->loadTemplate();
        }
            if ($this->element->main->product_layout('show_exc_vat')){
              $this->setLayout('listing_exc_vat');
                echo $this->loadTemplate();
        }
            else
              $this->setLayout('listing_price');
                echo $this->loadTemplate();
        }
	?></div>

Please Log in or Create an account to join the conversation.

  • Posts: 26266
  • Thank you received: 4044
  • MODERATOR
7 years 9 months ago #282736

Hello,

I'm sorry but I don't understand the code you wrote and it does not look it would work well.
I don't think that your "element->main" object contains a function named "product_layout".

Maybe you want to perform an equality test ?

Please understand that our support can help regarding the usage and configuration of HikaShop but if you need some help to create some custom code ; it would be better to ask to a professional.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Time to create page: 0.068 seconds
Powered by Kunena Forum