Zum Hauptinhalt springen
Ajax-Aktualisierungscode (Neue UI)

Verhindert die Weiterleitung zur Warenkorbseite beim Hinzufügen eines Angebots aus dem Ajax-Warenkorb

Lasandra Miller avatar
Verfasst von Lasandra Miller
Vor über 3 Monaten aktualisiert

Der Begriff „Ajax-Warenkorb“ bezieht sich auf die Warenkorb-Schublade, das Pop-up-Warenkorb oder den Schiebewarenkorb, den einige Geschäfte verwenden. Wenn Ihr Geschäft eines dieser speziellen Warenkörbe verwendet und Sie Upselling in diesen Warenkörben durchführen möchten, ist die In Cart Upsell-App genau das Richtige für Sie! Nachfolgend finden Sie ein Beispiel, wie ein Ajax-Warenkorb aussieht.

Der “Ajax Refresh” Code wird verwendet, um die Weiterleitung zur Warenkorbseite zu verhindern, wenn das Upsell, das von In Cart Upsell generiert wird, zum Warenkorb hinzugefügt wird. Der Code sorgt dafür, dass Ihre Käufer nach dem Hinzufügen des Upsells in der Warenkorb-Schublade “Ajax Cart” bleiben. Diese Codes sind einzigartig für Ihr Theme und werden normalerweise von den Entwicklern Ihres Themes bereitgestellt. Im Laufe der Jahre hat In Cart Upsell Ajax Refresh Codes für einige gängige Themes gesammelt.

Das erste, was Sie wissen müssen, ist der Name Ihres Themes. Sobald Sie das wissen, können Sie in unserer Liste der “Refresh Codes” nach Ihrem Theme-Namen suchen. Nachdem Sie Ihren Theme-Namen gefunden haben, kopieren Sie den Refresh-Code und fügen Sie ihn in der App ein, indem Sie zu den Einstellungen gehen, auf Ajax Cart klicken und dann den kopierten Code in das bereitgestellte Textfeld für den Ajax Refresh Code einfügen.

Theme Name

Refresh Code

Athens

document.querySelector('.nudge-offer').remove();

document.querySelector('form.mini-cart-inner input.quantity-input-field').dispatchEvent(new Event("change", { bubbles: true }));

InCartUpsell.prototype.findOfferWhenReady();

Atlantic

$('.nudge-offer').remove()

fetch('/cart?view=mini', {

credentials: 'same-origin',

method: 'GET'

}).then(function (content) {

content.text().then(function(html){

$('.cart-mini-content').html(html.replace('<script class="cartFlagX"></script>','').replace('<template data-options>','').replace('{}','').replace('</template>','').replace('<template data-html="content">','').replace('<template data-html="footer">',''))

$('.cart-mini-content .cart-mini-subtotal').remove()

$('.cart-mini-content .cart-mini-actions').remove()

$('.cart-mini-content .cartdrawer-information-header').remove()

})

})

$('.quantity .field').trigger('change');<br>

Baseline

document.querySelector(".nudge-offer").remove();

document.body.dispatchEvent(new CustomEvent("baseline:modalcart:afteradditem"))

InCartUpsell.prototype.findOfferWhenReady();

Booster

HsCartDrawer.updateSlideCart();

Broadcast

document.querySelector(".nudge-offer").remove();

cart.getCart();

InCartUpsell.prototype.findOfferWhenReady();

Brooklyn

document.querySelector(".nudge-offer").remove();

ajaxCart.load();

InCartUpsell.prototype.findOfferWhenReady();

Cart.js

CartJS.getCart(); document.querySelector('.nudge-offer').remove(); InCartUpsell.prototype.findOfferWhenReady();

Colors

document.querySelector('.nudge-offer').remove();

document.querySelector('form.ajaxcart input.ajaxcart__qty-num').dispatchEvent(new Event("change", { bubbles: true }));

InCartUpsell.prototype.findOfferWhenReady();

Dawn

document.querySelector('.nudge-offer').remove();

document.querySelector('.nudge-offer').remove(); ajaxCart.load(); InCartUpsell.prototype.findOfferWhenReady();

Debut

closeAjaxCart();

ajaxCartUpdate();

Debutify

document.querySelector('.nudge-offer').remove();

theme.ajaxCart.update();

InCartUpsell.prototype.findOfferWhenReady();

------- OR -------

$(".nudge-offer").remove(); $("form.ajaxcart .ajaxcart__qty-num").first().trigger("change"); setTimeout( function(){ InCartUpsell.prototype.findOfferWhenReady(); }, 3000);

------- OR --------

Look for the following line in theme.js.liquid (Get collab access) and change it

FROM
module = {init: init};

TO
module = {
init: init,
__lcart: loadCart
};

Then the refresh code will be

AjaxCart.__lcart();

$(".nudge-offer").remove();

Editorial

$.ajax({

url: "/cart.js",

type: "GET",

_sellify: sellify,

success: function(resp){ this._sellify.ucd.helpers.ajaxCart.buildCart(resp); }

});

Ella

document.querySelector('.nudge-offer').remove();

document.querySelector('div.has-items input.item-quantity').dispatchEvent(new Event("change", { bubbles: true }));

InCartUpsell.prototype.findOfferWhenReady();

Expanse

document.querySelector('.nudge-offer').remove();

document.dispatchEvent(new CustomEvent('cart:build'));

InCartUpsell.prototype.findOfferWhenReady();

Flex

document.querySelector(".nudge-offer").remove();

Shopify.theme.jsAjaxCart.updateView();

InCartUpsell.prototype.findOfferWhenReady();

Flow

document.querySelector('.nudge-offer').remove();

document.querySelector('form.cart input.ajaxcart__qty-num').dispatchEvent(new Event("change", { bubbles: true }));

InCartUpsell.prototype.findOfferWhenReady();

Focal

document.querySelector('.nudge-offer').remove();

document.documentElement.dispatchEvent(new CustomEvent('cart:refresh', {bubbles: true}));

InCartUpsell.prototype.findOfferWhenReady();

FoxPad

document.querySelector('.nudge-offer').remove();

document.querySelector('form.cart-flyout__form input.quantity').dispatchEvent(new Event("change"));

InCartUpsell.prototype.findOfferWhenReady();

Go Live

document.querySelector('.nudge-offer').remove();

$("form.cart-form .cart__qty-input").first().trigger("change");

InCartUpsell.prototype.findOfferWhenReady();

Impulse

document.querySelector('.nudge-offer').remove();

$("form.ajaxcart .js-qty__num").first().trigger("change");

InCartUpsell.prototype.findOfferWhenReady();

or

document.querySelector('.nudge-offer').remove();

document.dispatchEvent(new CustomEvent('cart:build'));

InCartUpsell.prototype.findOfferWhenReady();

Minimal

$.getJSON("/cart.js", function(cart) {

refreshCart(cart);

});

Motion

var ajcresp = theme.cart.getCart();

try{

(new theme.CartDrawer()).buildCart(ajcresp.responseJSON);

}

catch (e){

var oa = 1;

}

Narrative

$(".nudge-offer").remove();

$("form.cart-drawer .cart-drawer__item-quantity").first().trigger("input");

Parallax

ajaxUpdateCart(1, $(this).val(), $(this).parents('#cart'));<br>

Pipeline

Shopify.getCart(ajaxifyShopify.buildCart);!Important: Change Line 1131 in Ajaxify.js.liquidFROMmodule = {

init: init

};TOmodule = {

init: init,

buildCart: buildCart;

};

document.querySelector('.nudge-offer').remove();

document.querySelector('div.drawer__content input.quantity__input').dispatchEvent(new Event("change", { bubbles: true }));

InCartUpsell.prototype.findOfferWhenReady();

Pop

document.querySelector('.nudge-offer').remove();

document.querySelector('div.ajaxifyCart--content input.ajaxifyCart--num').dispatchEvent(new Event("change", { bubbles: true }));

InCartUpsell.prototype.findOfferWhenReady();

Prestige

fetch('/cart?view=drawer&timestamp=' + Date.now(), {

credentials: 'same-origin',

method: 'GET'

}).then(function (content) {

content.text().then(function(html){

document.getElementById("sidebar-cart").innerHTML = html;

document.getElementById("sidebar-cart").children[0].setAttribute("aria-hidden", "false");

})

})

OR

jQuery.get('/cart?view=drawer&timestamp=' + Date.now(), function(data, textStatus, jqXHR) {

jQuery("#sidebar-cart").html(jQuery(jQuery.parseHTML(data)).filter("#sidebar-cart").html());

jQuery("#sidebar-cart").attr("aria-hidden", false);

jQuery("#sidebar-cart").attr("tabindex", "-1");

if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {

if (browserRatio >= 1.5) {

jQuery("#sidebar-cart").attr("style", "min-height: 360px;");

} else {

jQuery("#sidebar-cart").attr("style", "min-height: 555px;");

}

} else {

jQuery("#sidebar-cart").attr("style", "height: 100vh !important;");

}

});

OR

document.querySelector('.nudge-offer').remove();

document.documentElement.dispatchEvent(new CustomEvent('cart:refresh', {bubbles: true}));

InCartUpsell.prototype.findOfferWhenReady();

Refresh

document.querySelector('.nudge-offer').remove();

document.querySelector('form.cart__contents input.quantity__input').dispatchEvent(new Event("change", { bubbles: true }));

InCartUpsell.prototype.findOfferWhenReady();

Ride

document.querySelector('.nudge-offer').remove();
document.querySelector('form.cart__contents input.quantity__input').dispatchEvent(new Event("change", { bubbles: true }));
InCartUpsell.prototype.findOfferWhenReady();

Sense

document.querySelector('.nudge-offer').remove();

document.querySelector('form.cart__contents input.quantity__input').dispatchEvent(new Event("change", { bubbles: true }));

InCartUpsell.prototype.findOfferWhenReady();

Shella

document.querySelector('.nudge-offer').remove();

theme.cart.updateData()

setTimeout(() => { theme.cart.updateCart(); }, 1000);

SlideCart

window.SLIDECART_UPDATE();

OR

window.SLIDECART_UPDATE(function() {

window.SLIDECART_OPEN()

});

Full list of SlidecartHQ callbacks

https://apphq.co/documentation/slide-cart-callbacks-and-methods

Starter

setTimeout(function(){

$(window).trigger('updateCart');

}, 100)

Streamline

theme.cart._updateCart();

$(".nudge-offer").fadeOut(400,function(){ $(".nudge-offer").remove() });

OR

document.dispatchEvent(new CustomEvent("cart:build"))

document.querySelector(".nudge-offer").remove();

InCartUpsell.prototype.findOfferWhenReady();

Supply

$(".nudge-offer").remove();

$("form.cart-form .ajaxifyCart--num").first().trigger("change");

setTimeout(function(){ InCartUpsell.prototype.findOfferWhenReady(); },3000);

Testament

document.querySelector('.nudge-offer').remove();

Shopify.getCart(ajaxifyShopify.buildCart);

InCartUpsell.prototype.findOfferWhenReady();

Turbo

$("[data-cart-quantity-input]").first().clone(true,true).val(1).css("display","none").appendTo($("[data-cart-quantity-input]").first().closest(".product-quantity-box")).trigger("change");

OR

$("input.quantity").first().clone(true,true).val(1).css("display","none").appendTo($("input.quantity").first().closest(".product-quantity-box")).trigger("change");

Vella Framework

$('.drawerProductQty .qtyNum').first().trigger("change");

$(".nudge-offer").remove();

InCartUpsell.prototype.findOfferWhenReady();

Venture

document.querySelector(".nudge-offer").remove();

fetchCart();

InCartUpsell.prototype.findOfferWhenReady();

Venue

document.querySelector('.nudge-offer').remove();

document.querySelector('form.cart input.ajaxcart__qty-num').dispatchEvent(new Event("change", { bubbles: true }));

InCartUpsell.prototype.findOfferWhenReady();

Vision

document.querySelector('.nudge-offer').remove();

document.documentElement.dispatchEvent(new CustomEvent('cart:refresh', {bubbles: true}));

InCartUpsell.prototype.findOfferWhenReady();

Warehouse

document.querySelector('.nudge-offer').remove();

document.documentElement.dispatchEvent(new CustomEvent('cart:refresh', {

bubbles: true}));

InCartUpsell.prototype.findOfferWhenReady();

Zen

document.querySelector('.nudge-offer').remove();

document.querySelector('div.ajaxifyCart--content input.ajaxifyCart--num').dispatchEvent(new Event("change", { bubbles: true }));

InCartUpsell.prototype.findOfferWhenReady();

Hat dies deine Frage beantwortet?