- Posts: 94
- Thank you received: 2
Link to productpage in email from productpage
4 years 9 months ago #338710
by RustyHika
Link to productpage in email from productpage was created by RustyHika
-- 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!
-- 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!
Please Log in or Create an account to join the conversation.
4 years 9 months ago #338712
by nicolas
Replied by nicolas on topic Link to productpage in email from productpage
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.
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.
4 years 9 months ago #338754
by RustyHika
Replied by RustyHika on topic Link to productpage in email from productpage
Hi Nicolas,
Is it possible to change the link from back-end URL to front-end URL of the product?
Cheers, Remco
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.
4 years 9 months ago #338759
by nicolas
Replied by nicolas on topic Link to productpage in email from productpage
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 :
to:
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.
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 :
Code:
if(!empty($front__url))
$vars['PRODUCT_DETAILS'] .= ' <a href="'.$front__url.'">'.JText::_('FRONTEND_DETAILS_PAGE').'</a>';
Code:
if(!empty($front_url))
$vars['PRODUCT_DETAILS'] .= ' <a href="'.$front_url.'">'.JText::_('FRONTEND_DETAILS_PAGE').'</a>';
We'll add that fix on our end for the next version.
Please Log in or Create an account to join the conversation.
4 years 9 months ago #338802
by RustyHika
Replied by RustyHika on topic Link to productpage in email from productpage
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!
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.
4 years 9 months ago #338807
by nicolas
Replied by nicolas on topic Link to productpage in email from productpage
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
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.
4 years 9 months ago #338853
by RustyHika
Replied by RustyHika on topic Link to productpage in email from productpage
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
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
Please Log in or Create an account to join the conversation.
4 years 9 months ago #338858
by nicolas
Replied by nicolas on topic Link to productpage in email from productpage
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:
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...
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:
Code:
/******* 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 ******/
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.
4 years 9 months ago #338934
by RustyHika
Replied by RustyHika on topic Link to productpage in email from productpage
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
Thanks for the extended info you gave me. Appreciated
Cheers,
Remco
Please Log in or Create an account to join the conversation.
4 years 9 months ago #338937
by nicolas
Replied by nicolas on topic Link to productpage in email from productpage
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 :
Then, I could either replace the text in $this->element->product_name before the require, like this:
Or I could replace the text from the resulting 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.
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 :
Code:
<?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:
Code:
<?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');
Code:
<?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
The following user(s) said Thank You: RustyHika
Please Log in or Create an account to join the conversation.
4 years 9 months ago #338968
by RustyHika
Replied by RustyHika on topic Link to productpage in email from productpage
Time to learn PHP
Please Log in or Create an account to join the conversation.
Time to create page: 0.074 seconds