PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 12/12/2019 4:17 PM by  Will Strohl
Product listings for affiliate programs
 7 Replies
 1 Subscribed to this topic
 1 Subscribed to this forum
Sort:
You are not authorized to post a reply.
Page 2 of 2 << < 12
Author Messages





New Member






--
12/10/2019 5:24 PM
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:


$(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);

}
});


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.





Veteran Member






--
12/12/2019 4:16 PM
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





Veteran Member






--
12/12/2019 4:17 PM
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....ting-Custom-Viewsets
Will Strohl, Upendo Ventures Hotcakes Cloud | Get Support | Code Support Official Cloud & Support provider for Hotcakes
You are not authorized to post a reply.
Page 2 of 2 << < 12


Loading
  • Sign-up for the Hotcakes Community Newsletter: