Category displays price when variants are present

  • Posts: 15
  • Thank you received: 0
12 years 1 month ago #71690

The shop has a product, within a sub-category, that has 2 characteristics (size and style) and variants - price (per size) and quantity (per style). The main product has no price defined, price being defined by variant. However, when the sub-category to which the product belongs is displayed, it shows a price of '£20 each' (the lowest price defined by variant). This is misleading, as the price is variant depending on size. How can I prevent the display of the price when the sub-category is displayed? Please see the image attached - the '£20 each' should not be there. Thanks.

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
12 years 4 weeks ago #71863

Hi,

One solution could be to create a custom field on the table product and with the label "displayprice" in HikaShop > Display > Custom fields, then edit the view "product / listing_img_title" in HikaShop > Display > Views.

In this view replace the code:

	if($this->params->get('show_price','-1')=='-1'){
		$config =& hikashop_config();
		$this->params->set('show_price',$config->get('show_price'));
	}
	if($this->params->get('show_price')){
		$this->setLayout('listing_price');
		echo $this->loadTemplate();
	}

By:
if(isset($this->row->displayprice) && $this->row->displayprice == 'no'){
	if($this->params->get('show_price','-1')=='-1'){
		$config =& hikashop_config();
		$this->params->set('show_price',$config->get('show_price'));
	}
	if($this->params->get('show_price')){
		$this->setLayout('listing_price');
		echo $this->loadTemplate();
	}
}

Then in the product edition page, just set "no" in the custom field for the products with variants.

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

  • Posts: 15
  • Thank you received: 0
12 years 4 weeks ago #71933

Thanks - I'll try this in the next day or two. It does seem a bit user-unfriendly to need to amend core code to overcome what seems to be a flaw in the system. Perhaps you could take this on board for future versions? I'll report back on how I get on with your solution.

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

  • Posts: 15
  • Thank you received: 0
12 years 4 weeks ago #71973

I am unable to add a custom field to table 'product' via back-end: if I click New, the table selected is Address and is not a drop-down menu to be able to select Product table. So, I tried adding the new field via phpmyAdmin (displayprice, varchar(255)). I amended the code in listing_img_title as you specify (do you need 2 curly brackets at the end of the revised code?) However, I don't see anywhere the new field to input 'no' - what do you mean by the 'product edition'? I assume you mean the page to create/amend product details? Thanks

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 4 weeks ago #71994

The "table" dropdown is only available in commercial editions of HikaShop. You must be using the Starter edition which does not allow for that.
You can't just add the field via the database as it's more complex to do.

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

  • Posts: 15
  • Thank you received: 0
12 years 4 weeks ago #72107

Yes, I'm using the Starter edition, so I guess this solution can not now be applied.

Last edit: 12 years 4 weeks ago by keithyoung89. Reason: I confused the issue!

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

Time to create page: 0.079 seconds
Powered by Kunena Forum