Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
updated code to reflect Saleor approach to passing JS values
Jon Lawrence95ac6ada7048
diff --git a/saleor/static/js/components/cart.js b/saleor/static/js/components/cart.jsindex 76d6957be5..3aa5766cb6 100644--- a/saleor/static/js/components/cart.js+++ b/saleor/static/js/components/cart.js@@ -1,6 +1,6 @@import {getAjaxError} from './misc';-export var summaryLink = '/cart/summary/'; /* overriden in base.html to url 'cart:cart-summary' */+export const summaryLink = $('html').data('cart-summary-url');export const $cartDropdown = $('.cart-dropdown');export const $cartIcon = $('.cart__icon');export const $addToCartError = $('.product__info__form-error small');@@ -28,7 +28,6 @@ export const onAddToCartSuccess = () => {export default $(document).ready((e) => {// Cart dropdown- summaryLink = cartURL; // override from base.html$.get(summaryLink, (data) => {$cartDropdown.html(data);});@@ -133,7 +132,7 @@ export default $(document).ready((e) => {let deliveryAjax = (e) => {let newCountry = $(countrySelect).val();$.ajax({- url: shippingOptionsURL, // this is set in base.html to cart:shipping-options+ url: $('html').data('shipping-options-url'),type: 'POST',data: {'csrfmiddlewaretoken': crsfToken,diff --git a/templates/base.html b/templates/base.htmlindex eecd0195a1..f0e5e30e61 100644--- a/templates/base.html+++ b/templates/base.html@@ -3,7 +3,7 @@{% load staticfiles %}{% load render_bundle from webpack_loader %}-<html lang="{{ LANGUAGE_CODE }}" class="no-js">+<html lang="{{ LANGUAGE_CODE }}" class="no-js" data-shipping-options-url="{% url 'cart:shipping-options' %}" data-cart-summary-url="{% url 'cart:cart-summary' %}"><head><title>{% block title %}{{ site.name }}{% endblock %}</title>{% block meta %}@@ -266,10 +266,6 @@{% endblock %}{% block footer_scripts %}<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>- <script type="text/javascript">- var cartURL = "{% url 'cart:cart-summary'%}";- var shippingOptionsURL = "{% url 'cart:shipping-options' %}";- </script>{% render_bundle 'vendor' 'js' %}{% render_bundle 'storefront' 'js' %}{% endblock footer_scripts %}