Dlarryb
  •  Dlarryb
  • 53.25% (Neutral)
  • Newbie Topic Starter
2019-12-10T15:24:41Z
Is there a way to add a product that will link to another website without adding it to the cart?
Will Strohl
2019-12-10T15:55:59Z
What do you mean by "a product that will link to another website?"
Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
Dlarryb
  •  Dlarryb
  • 53.25% (Neutral)
  • Newbie Topic Starter
2019-12-10T16:02:07Z
I have affiliate agreements with a couple of different e-commerce websites and would like to list products from those sites. What I would like to do is enter all of the product information so that the products are indexed on my site. Subsequently, I would like to display the product to customers and then provide a link that they would click on to view/purchase the product from the respective e-commerce website.
Will Strohl
2019-12-10T16:16:47Z
Ah... Now I know what you mean. 🙂

I have a future project where I may doing that very same thing. What I plan on doing for those products is setting them up using Product Types and Product Type Properties.

https://hotcakescommerce.../210466763-Product-Types 
https://hotcakescommerce...-Product-Type-Properties 

A product type property you'd add would be Text. For products that link out to other websites, you'd look for this property and then replace the Add to Cart button with a Buy on Other Website button using that value. This also allows for stores where you have a mix of local and off-site products. Alternatively, you can check for that value and show no button (and/or e-mail yourself in case you missed a product type value).

https://hotcakescommerce...-Product-Type-Properties 
Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
Dlarryb
  •  Dlarryb
  • 53.25% (Neutral)
  • Newbie Topic Starter
2019-12-10T16:26:22Z
Thank you very much. I had a feeling that product types would be my starting point. I assume that you use js or jquery to replace the Add to cart button?
Dlarryb
  •  Dlarryb
  • 53.25% (Neutral)
  • Newbie Topic Starter
2019-12-10T21:24:51Z
I got it working. My goal was to replace the Add to Cart with a button that would take a user to an external website to purchase the product. I also wanted to load an external image as the product image.

Here are the steps that I took:

1. Created a Property type with name of my external website.
2. Created a Property type Property called "External URL:"
3. Created a Property type Property called "Image URL:"
4. Created the product and added the external URL and Image URL.

I then added the following script to the PropertyViewerView.ascx file:

<script type="text/javascript">
$(window).on('load', function() {
if ($('.hc-typedisplay')[0]) {
$('.hc-typedisplay').hide();
var u = $('.hc-typedisplay span').text().replace('External URL:', '');
var ar = u.split('Image URL:');
var uhtml = '<li><a href="' + ar[0] + '" target="_blank" class="dnnPrimaryAction">Purchase Options</li>';
$("meta[property='og:image']").attr('content', ar[1]);
$('#hcProductImage').attr('src',ar[1]);
$('#hcProductActions').html(uhtml);

}
});
</script>

Notes:
1. The script first checks to see if Property Type Properties are present. If they are, it proceeds. If you use additional Property Type Properties for other purposes, you will need to be more specific in your validation.

2. There is no way to collect each Property Type Property individually. I opted to use the hc-typedisplay class to collect the Property Type Properties. I could have drilled down to hc-propertyvalue class but both values are concatenated upon collection and thus I did not have a delimiter to split.

3. Upon collecting the Property Type Properties, I then use the External URL to replace the Add to Cart button with a button styled link. I then use the Image URL to replace the "missing" product image src.

4. I am using Hotcakes under DNN and thus I am using the dnnPrimaryAction class to display my link as a button.

5. Obviously the script will need to be re-inserted if Hotcakes is updated.
Will Strohl
2019-12-12T20:16:07Z
Thanks for the updates. This looks really good. Personally, I think it would be better to replace the button with Razor instead of JS though. 🙂 Well done!
Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
Will Strohl
2019-12-12T20:17:36Z
Oh, one more thing... If you're concerned about changes and scripts being overwritten during upgrades, then you're probably not using a custom viewset. It sounds like you're making updates in the default viewset. You should instead create and maintain your own custom viewset instead. 🙂

https://hotcakescommerce...Creating-Custom-Viewsets 
Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
Users browsing this topic
    Loading
    • Sign-up for the Hotcakes Community Newsletter: