Let main product description always visible

  • Posts: 256
  • Thank you received: 7
4 hours 27 minutes ago #370773

Hi,
When using variants, the variant's description is displayed and the main product description is hidden as soon as you select a variant, as long as the variant's description exists.
This is the expected behavior. However, we would like the main product description to always be displayed (above or below) the selected variant description. In our case, the main description does not change much from one variant to another, so it would be simpler not to have to copy, paste and maintain the same description for each variant.

Apparently the main description is always present in the DOM (display:none) and is changed via JavaScript upon the variant selection event.

Is there a simple way to always keep the main description visible?

Thanks.

Laurent

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

  • Posts: 85241
  • Thank you received: 13917
  • MODERATOR
25 minutes ago #370775

Hi,

The variant selection mechanism works by replacing the innerHTML of the hikashop_product_description_main div with the variant's description content. So it's not just a CSS display toggle. That means a pure CSS solution won't work here.

The simplest approach is to create a view override of the show_default.php template and add a second description div with a different ID, so the variant swap logic won't touch it. You can do this from the backend via Display > Views and add, right above or below the existing description block, something like:

  <!-- FIXED MAIN DESCRIPTION -->
  <div class="hikashop_product_main_description_fixed"><?php
      $mainProduct = !empty($this->element->main) ? $this->element->main : $this->element;
      echo JHTML::_('content.prepare', preg_replace('#<hr *id="system-readmore" */>#i', '', $mainProduct->product_description));
  ?></div>
  <!-- EO FIXED MAIN DESCRIPTION -->
Since this div doesn't use the hikashop_product_description_main ID, the JavaScript variant swap function will leave it alone. The main description will always stay visible, and the original description block below (or above) will continue to swap to show the selected variant's description as usual.

If you want the variant description block to only appear when a variant actually has its own description (and not just repeat the main description), you could also leave the variant descriptions empty and only fill them for variants that have specific extra information.

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

Time to create page: 0.069 seconds
Powered by Kunena Forum