Custom js on specific product

  • Posts: 134
  • Thank you received: 6
9 years 2 weeks ago #220365

-- HikaShop version -- : 2.6.0

Hi,

how could I develop customised Modal message which contains links to some actions on specific product.

I have a Child Party Club site. The main purpose of HikaShop there is that the clients have the ability to request a party for their children. So the main product is Child Party. It has some options and characteristics (number of childs invited, predefined child food menus... etc.), but I would like to give the client the ability to add some more products (food for the parents for example).

So I would like to make custom modal, only for the product Child Party. That modal should give the oportunity (if he would like) to the client to order food and drinks for the parents. So it should contain two buttons:
1. Choose food and drinks
2. Continue with checkout.

For the other products the default popup should be present.


In other words, how could I add custom JS to specific product.

Last edit: 9 years 2 weeks ago by filiar.

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

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
9 years 1 week ago #220407

Hi,

If you want to add custom javascript on the product page, you can edit the file "show_default" via the menu Display>Views and add it there.

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

  • Posts: 134
  • Thank you received: 6
9 years 1 week ago #220451

My question as stated in the topic title is about customisation of a specific (exact one single product) not the whole product page.

And it is about what happens when clicking on add to card button.
I have to redirect the client (somewhere) after adding to card ONE EXACT product. For all the others the defaults are ok.

And as I found, the page is reloaded after adding to card and notice is shown that gives one the choise to continue or to finalize.

How can I skip that notice (for the exact one product) and redirect somewhere instead?

Last edit: 9 years 1 week ago by filiar.

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

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
9 years 1 week ago #220464

Hi,

It's that code which displays the popup when the product page refreshes after the add to cart:

if($app->getUserState( HIKASHOP_COMPONENT.'.popup', '0')) {
				$js = $this->getJS();
				$app->setUserState( HIKASHOP_COMPONENT.'.popup', '0');
			}
in the file components/com_hikashop/views/product/view.html.php
So you would have to change the content of that if and instead do a redirection ( the header function of PHP on the location ).
Doing it for only one product is dead simple. Just check on the cid in the $_REQUEST array which contains the product_id of the current product.

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

  • Posts: 134
  • Thank you received: 6
9 years 1 week ago #220528

Thank you, Nicolas. I think that was the answer I was looking for!

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

Time to create page: 0.063 seconds
Powered by Kunena Forum