How to use a custom field in product listing table

  • Posts: 19
  • Thank you received: 0
11 years 10 months ago #84267

Hello,

I have created a custom field named salemethod which contains the unit of measure for the product being sold (Pc, Set, Case, etc). I have managed to get it to appear on the product page but would like to also have it show up on the product listing page with the price. Instead of reading "$40.00 when you buy 5" I would like it to read "As low as $40.00 per SET. Most of my items have minimum quantity prices set up.

Where can I accomplish this and can it be done the same I did it on the product page?

In the menu Display -> Views, edit the product / listing_price.php file.
In this file, replace:
echo JText::_('PER_UNIT');
By:
if(isset($this->element->main)) echo JText::_($this->element->main->salemethod);
elseif(isset($this->row)) echo JText::_($this->row->salemethod);
else echo JText::_($this->element->salemethod);

Thank you,
Jeff
www.legacyetchings.com

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
11 years 10 months ago #84405

Hi,

Yes it can be done in the same file, I think that you have to add another check on the line "echo JText::_('PER_UNIT');" to change the text depending on if it's in a listing or a product page.

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

  • Posts: 19
  • Thank you received: 0
11 years 10 months ago #84644

Thanks Xavier, Could you give me an example please? I appreciate your help.

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

  • Posts: 13201
  • Thank you received: 2322
11 years 10 months ago #84709

You can use something like:

					if($this->row->salemethod == "set"){
						echo JText::_('PER_SET'); // for "per set"
					}else{
						echo JText::sprintf('PER_UNIT_AT_LEAST_X_BOUGHT',$price->price_min_quantity);
					}
				}else{
And use it at the top of the file too, for:
					if($this->row->salemethod == "set"){
						echo JText::_('START_PER_SET'); //for "As low as"
					}else{
						echo echo JText::_('PRICE_BEGINNING');
					}
				}else{

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

  • Posts: 19
  • Thank you received: 0
11 years 10 months ago #84790

I really hate to ask you this but could you please point out where in the code I should insert this? I tried a dozen places and only succeeded in breaking the shop.

This is the last thing I really need to get finished before I start to promote my site and start selling.

You've been great, thank you!

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

  • Posts: 13201
  • Thank you received: 2322
11 years 10 months ago #84839

For the first part of the code, you have to replace the line "echo JText::sprintf('PER_UNIT_AT_LEAST_X_BOUGHT',$price->price_min_quantity);" by the code.
And the second part, replace the line "echo echo JText::_('PRICE_BEGINNING');".

The following user(s) said Thank You: jeff_heilman@comcast.net

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

  • Posts: 19
  • Thank you received: 0
11 years 10 months ago #84964

I've tried your code several ways, thanks! However I'm still doing something wrong, it breaks the page. Here's how I have it:

  if(empty($this->row->prices)){
    echo JText::_('FREE_PRICE');
  }else{
    $first=true;
    if($this->row->salemethod == "Set"){
	echo JText::_('START_PER_SET');
	}else{
	echo JText::_('PRICE_BEGINNING');
	}
	}else{
    $i=0;
	 echo '</span> ';

Could you please tell me what I did wrong? Thank you!
Jeff

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

  • Posts: 2334
  • Thank you received: 403
11 years 10 months ago #85074

Hi there,

I think this line

}else{
shouldn't be there ;)

The following user(s) said Thank You: jeff_heilman@comcast.net

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

  • Posts: 19
  • Thank you received: 0
11 years 10 months ago #85135

Thanks for all of your help guys, I just can't seem to get it to work. I'm going to explore some other ways to sell the products by the piece that makes sense.

Could you recommend a freelancer that could do this for me?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 years 10 months ago #85246

You can contact the PolishedGeek team. They specialized in ecommerce extensions customization and extensions development:
polishedgeek.com/

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

  • Posts: 2
  • Thank you received: 0
11 years 10 months ago #85255

So is it actually possible to create a custom field on the product listing page.

I want to have a summary description and a couple of text fields on the product listing page, if i create custom fields how would I go about dispaying those fields on the product listing page.

I have followed this thread but I am still unclear any help would be appreciated

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

  • Posts: 19
  • Thank you received: 0
11 years 10 months ago #85300

Hi Menzer,

I've been able to get this to work: www.hikashop.com/en/support/documentation/faq.html#each but haven't had much luck beyond that. You might be able to build on it.

My .php skills are minimal, I know just enough to screw things up. ;) For now I decided to restructure the way I'm selling things and to revisit this in the future. If you come up with a solution could you please let me know?

Thanks and good luck!

Last edit: 11 years 10 months ago by jeff_heilman@comcast.net. Reason: fix link.

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

  • Posts: 2
  • Thank you received: 0
11 years 10 months ago #85320

Hi thanks for replying, I am just like you in terms of php knowledge, just wish I had the time top learn... Anyway... That link suggests that I can add custom fields to the product listings page which is what I want, however I only have the standard version at the moment and you have to have commercial version to creat custom fields for products. So I cannot try this yet.

I cannot find the custom field for product sections discussed below in my configuration area so I assume that is because I don't have a commercial version.

Custom item fields don't appear on the front end.

When you create a custom field, don't forget to enable the "Front-end" option.
Be careful, when you create the custom field, be sure that you set the good table , which is the "item" table, not the "product" table.
For products listings, enable the default option in System->configuration->display, enable "Display custom item fields" in the Default parameters for products.
For products listings, enable the same option, in Display->content menus/modules.

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

Time to create page: 0.091 seconds
Powered by Kunena Forum