Description of variants on category listing page

  • Posts: 121
  • Thank you received: 2
3 years 2 months ago #328350

-- HikaShop version -- : 4.4.0
-- Joomla version -- : 3.9.23
-- PHP version -- : 7.3.25
-- Browser(s) name and version -- : Firefox

I've set up monthly, annual and biannual subscription periods as product variants of the services offered in the webhosting category. This allows customers now to select between available subscription periods. So far so good.

However, when I go to the category list page for the webhosting product category, the page doesn't look like I want.



The subscription period variants (monthly, annual or biannual) have neither name nor description, only a price, which is what I want for the single product view page ( infinitymind.consulting/component/hikash...t/15-standard-server ), but not for the product category list page ( infinitymind.consulting/joomla-hosting ).

What's even weirder is that, for the "Enterprise Server", the annual subscription variant is displayed before the monthly variant.

Attachments:
Last edit: 3 years 2 months ago by andrewwinkler.

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

  • Posts: 4486
  • Thank you received: 609
  • MODERATOR
3 years 2 months ago #328370

Hello,

In order to better understand the context can you provide these elements :
- Relative Item Menu configuration screenshot (Product options tab)
- An Url link to directly see the context
- Did you have some override view on your product/listing_price ?

Awaiting your elements to better help you.
Regards

Last edit: 3 years 2 months ago by Philip.

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

  • Posts: 121
  • Thank you received: 2
3 years 2 months ago #328445

Just to be clear, what I want to change on the page displayed above (and linked to below) is that I want that it says what the different variant prices are for, that is monthly, annual or biannual subscription, above or next to the relevant price. And, of course, I don't want monthly and annual price mixed up for the enterprise server.

Here are the answers to your questions in your reply above:
URL: infinitymind.consulting/shop/hosting


I haven't used any overwrites as yet.

Attachments:
Last edit: 3 years 2 months ago by andrewwinkler.

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

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
3 years 2 months ago #328453

Hi,

A products listing display products not variants.
When a product has variants with prices but that the main product itself doesn't have any prices, then the system will automatically get the prices of the variants for the product on the listing.
Then, based on the "which price" setting of the menu item / module, it will display the prices.
Here, I can see that you set that setting to show all the prices, so it's actually displaying all the prices of all the variants as if they were prices of the main product.
I suppose that it would make more sense to only display the monthly price on the products listing. You can do so by selecting "cheapest" in the "which price" setting.
Then, if you want to, you can customize the file product / listing_price.php via the menu Display>views to add some test on the listing like for exemple "starting at " before the price and "per month" after it.

The following user(s) said Thank You: andrewwinkler

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

  • Posts: 121
  • Thank you received: 2
3 years 2 months ago #328470

Perfect. Now it only shows the cheapest price, i.e. the monthly subscription fee.


However, I still need to insert that this is the monthly hosting fee. Doing so by editing the HikaShop code is a problem though, since it would apply that change to all products, not only to products from the webhosting category. That wouldn't make sense for products with annual subscription fees or products sold such as the items in the "development" or "technology" category.

Attachments:
Last edit: 3 years 2 months ago by andrewwinkler.

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

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
3 years 2 months ago #328481

Hi,

Well, no really. In your custom code in product / listing_price.php, you have access to $this->element on the listing pages. This variable contains the information of the current category. So you just need a check, for example on $this->element->category_id so that you can display different things based on the current category.

Now, if you're not into coding, what you can do is to change the "each" dynamically.
On our FAQ page ( www.hikashop.com/support/documentation/106-faq.html ), with have a section where we explain how to do:
"I sell packed products, how can I change "each" text in the product page ?"
So that way, in each product you'll be able to configure, with the help of a custom field, what text you want to be instead of "each".

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

  • Posts: 121
  • Thank you received: 2
3 years 2 months ago #328498

I don't like either method.

1. having to change the code of HikaShop to make it display different selling unit labels for different product groups, instead of using "each" for everything is not exactly user-friendly. Instead, there should be a field in the product definition, allowing shop admin to change it from"each" to something else such as "per month".
2. modifying language overrides to change "each" to something else, doesn't work for me, since this change only makes sense for the hosting products, but not for other product categories such as developer hours, joomla extensions or computer products.

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

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
3 years 2 months ago #328511

Hi,

The modification from the FAQ I propose is pretty much what you're talking about on your point 1. It just requires 3 lines of code to change, and note that the change is done as a view override and thus won't be a problem for future updates.
I'm sorry but I don't have any other optoin to propose you with the current version of HikaShop.
Now I agree that it could be a nice improvement in the future to have an option for it in the product, but that won't help you achieve this in the short term.

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

  • Posts: 121
  • Thank you received: 2
3 years 2 months ago #328551

Well, I got stock at this step.

In the menu Display -> Views, edit the product / listing_price.php file. In this file, replace:
echo '<span class="hikashop_product_price_per_unit">'.JText::_('PER_UNIT').'</span>'; 

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);
I couldn't find that string to replace.

Attachments:

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

  • Posts: 4486
  • Thank you received: 609
  • MODERATOR
3 years 2 months ago #328569

Hello,

you have to edit your view in another program it's more easy to use, here you issue is because the part with the code isn't display in the window.
I check the code you look for, and it's present in this code.
Regards

Last edit: 3 years 2 months ago by Philip.

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

  • Posts: 121
  • Thank you received: 2
3 years 2 months ago #328571

I normally code using Dreamweaver. Which file (in which directory) do I need to edit?

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

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
3 years 2 months ago #328581

Hi,

The search feature of your browser doesn't work with the code editor provided by Joomla to edit files (and which we're using here).
You can just scroll down and I'll find it around line 190.

If you want to edit the file locally, you don't need to look for the file.
Just copy / paste the whole code of the file in your screenshot into a texte file on your local computer (in a new file in dreamweaver for example). Then, search for the code we're talking about in the FAQ and you'll find it.
Then, after you do the modification, copy / paste it back in the HikaShop view file edition and save.
But it would be simpler to just replace the code directly in the editor we provide in HikaShop.

The following user(s) said Thank You: andrewwinkler

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

  • Posts: 121
  • Thank you received: 2
3 years 2 months ago #328605

Okay, I followed the steps in that FAQ recommendation, but it made no difference.
Here are my custom field settings:


And here's the code of my product/listing_price.php file from line 187:
if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $this->params->get('per_unit', 1)) {
				if($price->price_min_quantity > 1) {
					echo '<span class="hikashop_product_price_per_unit_x">'.JText::sprintf('PER_UNIT_AT_LEAST_X_BOUGHT',$price->price_min_quantity).'</span>';
				} else {
					/* replaced on recommendation by HikaShop FAQ 106 */
					/* echo '<span class="hikashop_product_price_per_unit">'.JText::_('PER_UNIT').'</span>';*/
					/* end of replace code */
     				/* start of replacement code */
      					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); 
					/* end of replacement code */
				}
			}

Attachments:
Last edit: 3 years 2 months ago by andrewwinkler.

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

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
3 years 2 months ago #328609

Hi,

If you don't see any difference, then either you're editing the view file for another template than the template you're using on your frontend, or you have some caching on your website that you need to clear to see the change.
Also, after you do these changes, you need to go into each product, select the value you want in that custom field and save the product so that it can be used by the modified code.

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

  • Posts: 121
  • Thank you received: 2
3 years 2 months ago #328618

Seriously, guys, this is way too complicated, far from what I would call user-friendly.
It's still not working after changing the sales method from "each" to "per month".


I doubt, it's got to do with caching, since "sale method" is now being displayed under the header "Specifications", at least for the product group "Hosting". For the product groups, development and extensions, nothing has changed though.
What am I doing wrong?
Update: for the time being, until this is resolved, I have unpublished the custom field "sale method".

Attachments:
Last edit: 3 years 2 months ago by andrewwinkler.

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

  • Posts: 4486
  • Thank you received: 609
  • MODERATOR
3 years 2 months ago #328662

Hello,

Provide via our Contact us form a backend access reference (with full access) in order to be able to check by ourselves.
Don't forget to add to your message an Url link to this subject, please.

Awaiting your returns to progress on your subject.
Regards

Last edit: 3 years 2 months ago by Philip.

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

  • Posts: 121
  • Thank you received: 2
3 years 2 months ago #328734

Done.

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

  • Posts: 4486
  • Thank you received: 609
  • MODERATOR
3 years 2 months ago #328744

Hello,

We have a look on your backend, and you haven't edited the right view see my screenshot to understand my point.


For your frontend you use the template ja_mixstore, and you have made your custom for the beez3 template

Now, to answer you on the fact that this operation is not "user-friendly".
You must understand that, here, we are on a code customization, so to have something simply "configurable" isn't possible, because it's building code process, by deriving from a view, thus technically making it simpler is not really possible.

And that's why we guide you not only to have what you have to ask but also for you that you master the tools better.
Regards

Last edit: 3 years 2 months ago by Philip.
The following user(s) said Thank You: andrewwinkler

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

Time to create page: 0.116 seconds
Powered by Kunena Forum