Passing in continue shopping URL
In recent versions of web browsers, if the domain between two URLs is different then Safari (and now Chrome) will not send the full referrer URL. Instead they are sending the just the domain. This change in browser behavior is done to try and limit invasive ad tracking technologies, but it has ramifications for websites using UltraCart in a checkout only method. Merchants will observe the behavior of the continue shopping button always taking the customer back to their home page.
Automatic Configuration Using JavaScript (Recommended)
The solution to this problem is to programmatically provide the current URL to the UCEditor endpoint using the OVERRIDECONTINUESHOPPINGURL parameter. If you place the following script on your page, it will find all your buy links, view cart links and buy forms and automatically fix them. This script does assume that you have jQuery present on your page.
Â
<!-- Place this script on the page -->
<script>
jQuery(document).ready(function(){
// Fix forms
jQuery("form").each(function(index, element) {
var $form = jQuery(element);
var action = $form.attr('action') || '';
// Is this form pointed at UC?
if (action.indexOf('UCEditor') >= 0) {
// Is it missing the hidden input
if (!$form.find("input[name='OVERRIDECONTINUESHOPPINGURL']").length) {
var $input = jQuery('<input type="hidden" name="OVERRIDECONTINUESHOPPINGURL" value="">');
$input.val(window.location.href);
$form.append($input);
}
}
});
// Fix links
jQuery("a[href]").each(function(index, element) {
var $a = jQuery(element);
var href = $a.attr('href') || '';
// Is this link pointed at UC and missing the parameter?
if (href.indexOf('UCEditor') >= 0 && href.indexOf('OVERRIDECONTINUESHOPPINGURL') === -1) {
href += "&OVERRIDECONTINUESHOPPINGURL=" + encodeURIComponent(window.location.href);
$a.attr('href', href);
}
});
});
</script>
Â
Manual Configuration for Forms
Let’s say that your existing form HTML looks like this:
<form method="post" action="https://secure.ultracart.com/cgi-bin/UCEditor">
<input type="hidden" name="merchantId" value="DEMO">
<input type="hidden" name="add" value="BOOTS">
<input type="hidden" name="quantity" value="1">
<input class="btn btn-sm btn-cart" type="submit" name="submit" value="Add To Cart">
</form>
You would need to modify the code by inserting an additional hidden input that contains the desired continue shopping URL as shown below.
<form method="post" action="https://secure.ultracart.com/cgi-bin/UCEditor">
<input type="hidden" name="merchantId" value="DEMO">
<input type="hidden" name="OVERRIDECONTINUESHOPPINGURL" value="https://www.mysite.com/boots.html">
<input type="hidden" name="add" value="BOOTS">
<input type="hidden" name="quantity" value="1">
<input class="btn btn-sm btn-cart" type="submit" name="submit" value="Add To Cart">
</form>
Â
Manual Configuration for Buy/View Cart Links
Assuming that your current buy link looks like:
and your page URL is:
You will need to take the URL of your current site and URL encode that value. You can do that with this site. The encoded value looks like this:
Finally you need to append that to the existing URL as the OVERRIDECONTINUESHOPPINGURL parameter. The final link would look like this:
Â