[Skip to main content](#vessel-content)

#   Linking to product variants from cart

##

- **[tjsan](/forum/user/4321-tjsan "View tjsan's Profile")**
- [![tjsan's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4321-tjsan "View tjsan's Profile") Topic Author
- [ Offline](/forum/user/4321-tjsan)

Less More

- Posts: 11
- Thank you received: 0
-
-

15 years 3 days ago [\#29679](#29679) by [tjsan](/forum/user/4321-tjsan "View tjsan's Profile")  *[Linking to product variants from cart](/forum/2-general-talk-about-hikashop/29679-linking-to-product-variants-from-cart#29679 "I have created a new product, let's call it &quot;widget&quot;. Widget has two characteristics, &quot;blue&quot; and &quot;red&quot;. I have also created two related products &quot;foo&quot; and &quot;bar&quot;, which are in an upublished category.  On the product page for widget, the related pruducts foo and bar are displayed.  When the widget is added to the cart, it is actually product widget:blue or widget:red that is added and when the user clicks on the product from within the cart, the variant product page is displayed - not the original product.  However, the variants are not linked to the related products so they do not appear on the product page.  Either, the link from the cart should go to the parent product instead of the variant OR the variant should also have the ability to specify related products.  What do you think?")* was created by *[tjsan](/forum/user/4321-tjsan "View tjsan's Profile")*

I have created a new product, let's call it "widget". Widget has two characteristics, "blue" and "red". I have also created two related products "foo" and "bar", which are in an upublished category.

On the product page for widget, the related pruducts foo and bar are displayed.

When the widget is added to the cart, it is actually product widget:blue or widget:red that is added and when the user clicks on the product from within the cart, the variant product page is displayed - not the original product.

However, the variants are not linked to the related products so they do not appear on the product page.

Either, the link from the cart should go to the parent product instead of the variant OR the variant should also have the ability to specify related products.

What do you think?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzI5Njc5LWxpbmtpbmctdG8tcHJvZHVjdC12YXJpYW50cy1mcm9tLWNhcnQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[tjsan](/forum/user/4321-tjsan "View tjsan's Profile")**
- [![tjsan's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4321-tjsan "View tjsan's Profile") Topic Author
- [ Offline](/forum/user/4321-tjsan)

Less More

- Posts: 11
- Thank you received: 0
-
-

15 years 3 days ago -  15 years 3 days ago [\#29700](#29700) by [tjsan](/forum/user/4321-tjsan "View tjsan's Profile")  Replied by *[tjsan](/forum/user/4321-tjsan "View tjsan's Profile")* on topic *[Re: Linking to product variants from cart](/forum/2-general-talk-about-hikashop/29679-linking-to-product-variants-from-cart#29700 "I have created a new product, let's call it &quot;widget&quot;. Widget has two characteristics, &quot;blue&quot; and &quot;red&quot;. I have also created two related products &quot;foo&quot; and &quot;bar&quot;, which are in an upublished category.  On the product page for widget, the related pruducts foo and bar are displayed.  When the widget is added to the cart, it is actually product widget:blue or widget:red that is added and when the user clicks on the product from within the cart, the variant product page is displayed - not the original product.  However, the variants are not linked to the related products so they do not appear on the product page.  Either, the link from the cart should go to the parent product instead of the variant OR the variant should also have the ability to specify related products.  What do you think?")*

I got this to work the I want by modifying the cart view as follows:

Replace this:
&lt;tbody&gt;
&lt;?php
$k = 0;
$this-&gt;cart_product_price = true;
$group = $this-&gt;config-&gt;get('group_options',0);
foreach($this-&gt;rows as $i =&gt; $row){
if(empty($row-&gt;cart_product_quantity)) continue;
if($group &amp;&amp; $row-&gt;cart_product_option_parent_id) continue;
}
?&gt;

With this:
&lt;tbody&gt;
&lt;?php
$k = 0;
$this-&gt;cart_product_price = true;
$group = $this-&gt;config-&gt;get('group_options',0);
foreach($this-&gt;rows as $i =&gt; $row){
if(empty($row-&gt;cart_product_quantity)) continue;
if($group &amp;&amp; $row-&gt;cart_product_option_parent_id) continue;

$prodlink_id = $row-&gt;product_id;
foreach($this-&gt;rows as $j =&gt; $r) {
if ($row-&gt;cart_product_parent_id == $r-&gt;cart_product_id) {
$prodlink_id = $r-&gt;product_id;
continue;
}
}
?&gt;

My only worry is that this might cause performance problems if there are a large number of products - what do you think?

Last edit: 15 years 3 days ago by [tjsan](/forum/user/4321-tjsan "View tjsan's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzI5Njc5LWxpbmtpbmctdG8tcHJvZHVjdC12YXJpYW50cy1mcm9tLWNhcnQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86555
- Thank you received: 14304
-
-

15 years 3 days ago [\#29718](#29718) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Linking to product variants from cart](/forum/2-general-talk-about-hikashop/29679-linking-to-product-variants-from-cart#29718 "I have created a new product, let's call it &quot;widget&quot;. Widget has two characteristics, &quot;blue&quot; and &quot;red&quot;. I have also created two related products &quot;foo&quot; and &quot;bar&quot;, which are in an upublished category.  On the product page for widget, the related pruducts foo and bar are displayed.  When the widget is added to the cart, it is actually product widget:blue or widget:red that is added and when the user clicks on the product from within the cart, the variant product page is displayed - not the original product.  However, the variants are not linked to the related products so they do not appear on the product page.  Either, the link from the cart should go to the parent product instead of the variant OR the variant should also have the ability to specify related products.  What do you think?")*

No problem with performances for that modification.

That indeed something we didn't think of.
The ideal solution would be to handle that case on the product page so that related products are displayed even if it's the variant id in the URL.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzI5Njc5LWxpbmtpbmctdG8tcHJvZHVjdC12YXJpYW50cy1mcm9tLWNhcnQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.061 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
