Link to productpage in email from productpage

  • Posts: 81
  • Thank you received: 2
  • Hikashop Business
4 months 2 days ago #338710

-- HikaShop version -- : 4.4.4
-- Joomla version -- : 3.10.4
-- PHP version -- : not applicable
-- Browser(s) name and version -- : not applicable
-- Error-message(debug-mod must be tuned on) -- : not applicable

Hi,

Is it possible to add a link to the product page in the email a shop owner receives when a visitor uses the contact button on that product page. Now it's hard to know about which product an inquiry has been made.

Cheers!

Attachments:

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

  • Posts: 75520
  • Thank you received: 11750
  • MODERATOR
4 months 1 day ago #338712

Hi,

There is already a link to the product page in that email.
It's probably that you've customized the "contact request" email via the menu System>Emails with the code of an old version of HikaShop and thus you didn't get the modifications we've added a while back to add the link.
Please check there.

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

  • Posts: 81
  • Thank you received: 2
  • Hikashop Business
4 months 23 hours ago #338754

Hi Nicolas,

Is it possible to change the link from back-end URL to front-end URL of the product?

Cheers, Remco

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

  • Posts: 75520
  • Thank you received: 11750
  • MODERATOR
4 months 19 hours ago #338759

Hi,

Both were supposed to be there already.
However, looking at the code, I can see a typo in the "preload" code of the email.
Change the code :

if(!empty($front__url))
		$vars['PRODUCT_DETAILS'] .= ' <a href="'.$front__url.'">'.JText::_('FRONTEND_DETAILS_PAGE').'</a>';
to:
if(!empty($front_url))
		$vars['PRODUCT_DETAILS'] .= ' <a href="'.$front_url.'">'.JText::_('FRONTEND_DETAILS_PAGE').'</a>';
in the preload of the contact request email and you'll also get the frontend URL.
We'll add that fix on our end for the next version.

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

  • Posts: 81
  • Thank you received: 2
  • Hikashop Business
4 months 2 hours ago #338802

Hi Nicolas,

Can you tell me where I can change this code? While it's not at system -> emails -> A contact request has been made. Nor the 'default' email template used there.

Thanks in advance!

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

  • Posts: 75520
  • Thank you received: 11750
  • MODERATOR
3 months 4 weeks ago #338807

Hi,

When you edit the email via the menu System>Emails and scroll down to the "preload" area, you can see that code around line 80:
i.imgur.com/L27cu1z.png

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

  • Posts: 81
  • Thank you received: 2
  • Hikashop Business
3 months 4 weeks ago #338853

Aaaah, thanks Nicolas! Never had to use the 'preload area'. Never too old to learn ;-)

Another question following this one (or better to start a new topic?) -> How to deal with this kind of modifications when updating Hikashop? Is there a way to know if a modification blocks new code added in the update? I see green and red colors when looking at the modification pages, but not sure how to interpret it fully and how to deal with it. See attachment I came across. This is a very old modification and I can't tell any more what has been modified at that time (Hikashop 2.3.5).

Cheers, Remco

Attachments:

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

  • Posts: 75520
  • Thank you received: 11750
  • MODERATOR
3 months 4 weeks ago #338858

Hi,

What is in red is the code which is in the default current version of the view file that can't be found in your override.
What is in green is the code in your override which can't be found in the default current version of the view.
So you can't know what was modified with this.
You can just know what is different from what is currently in HikaShop.
Also, as you can see if you look closely, most of the things highlighted there are because there are extra spaces, or the formatting of the code is different, but the code itself is actually the same.
But the tool comparing the code doesn't know it.

When you modify something in a view override, it's better to properly identify it as such.
For example you could add a rule to yourself so that whenever you change code in a view file, you add comments around like so:

/*******  change for fix which will be included in HikaShop see  https://www.hikashop.com/forum/product-category-display/903833-link-to-productpage-in-email-from-productpage.html ******/
if(!empty($front_url))
		$vars['PRODUCT_DETAILS'] .= ' <a href="'.$front_url.'">'.JText::_('FRONTEND_DETAILS_PAGE').'</a>';
/*******  end of change ******/
That way, when you go back to the view file, you can really see what you changed and why so that you can delete the whole override and add back your modifications to the new version of the view file if still necessary.

Another way to do it is to delete everything you have in the override, and actually require() the original view file and modify the HTML / variable around the require() so that you will always use the default view file with only your modifications around it. That's even better as you probably won't have to do anything with the view override in the future, and you'll automatically get the fixes and the new features in your override. But it's more complex to put in place...

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

  • Posts: 81
  • Thank you received: 2
  • Hikashop Business
3 months 3 weeks ago #338934

Hi Nicolas,

Thanks for the extended info you gave me. Appreciated ;-) Is there a (simple) way to learn how to modify the HTML / variable around the require()?

Cheers,
Remco

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

  • Posts: 75520
  • Thank you received: 11750
  • MODERATOR
3 months 3 weeks ago #338937

Hi,

Well, if you know PHP and read the original view file you should be able to figure out a way, but there is not a one size fits all solution. It's a concept.
For example, suppose I want to change the text "foo" to "bar" in the name of all the products when looking at the product page.
I would have to do an override of product / show_default where the product_name is displayed for the product details page.

In here, I would first require the whole code by just this :

<?php
require(JPATH_ROOT.'components/com_hikashop/views/product/tmpl/show_default.php');

Then, I could either replace the text in $this->element->product_name before the require, like this:
<?php
$this->element->product_name = str_replace('foo', 'bar', $this->element->product_name);
require(JPATH_ROOT.'components/com_hikashop/views/product/tmpl/show_default.php');
Or I could replace the text from the resulting HTML:
<?php
ob_start(); // start a buffer
require(JPATH_ROOT.'components/com_hikashop/views/product/tmpl/show_default.php');
$html = ob_get_clean(); // destroy the buffer and get its content
$html = preg_replace('#(<span id="hikashop_product_name_main" class="hikashop_product_name_main" itemprop="name">.*)foo(.*</span>)#U', '$1bar$2', $html); // do the replacing with a regex
echo $html; // display the modified HTML
Both will achieve the same thing, so since the first option is much simpler than the second, I would go with the first one. But in some cases, you can replace the variables before they are processed by the original view file and thus you need to process the HTML, usually with a regex, like the second solution above.

The following user(s) said Thank You: RustyHika

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

  • Posts: 81
  • Thank you received: 2
  • Hikashop Business
3 months 3 weeks ago #338968

Time to learn PHP ;-)

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

Time to create page: 0.076 seconds
Powered by Kunena Forum