ajax eliminare prodotto shopify id variante
Fri Jan 31 2025 15:27:49 GMT+0000 (Coordinated Universal Time)
Saved by
@StefanoGi
// theme.liquid
{% if customer and customer.tags contains 'b2b'%}
{% assign isb2b = true %}
{% else %}
{% assign isb2b = false %}
{% endif %}
{% comment %}
{% assign b2b_conf = ["hard-seltzer-boem-lattina-25cl" => "44854263415003"] %}
{% endcomment %}
{% assign b2b_conf =
'{"8257603272923": "44854263480539"}'
%}
<script>
var isb2b = {{isb2b}}
var b2bConf = {{ b2b_conf | parse_json }};
</script>
// sections/cart-template.liquid
{% if customer and customer.tags contains 'b2b'%}
{% assign isb2b = true %}
{% else %}
{% assign isb2b = false %}
{% endif %}
{% if isb2b %}
{%- for line_item in cart.items -%}
<script>
var line_item = {{line_item | json}};
if (b2bConf[line_item.product_id] != {{line_item.variant_id}}) {
$.ajax({
type: 'POST',
url: '/cart/change.js',
data: {
id: {{line_item.variant_id}},
quantity: 0
},
dataType: 'json',
success: function() {
window.location.reload();
},
error: function(err) {
console.error('Errore durante l\'aggiornamento del carrello:', err);
}
});
}
</script>
{%- endfor -%}
{% endif %}
content_copyCOPY
Comments