removing item from cart if condition not match.shopify - shopify

I can add a free product in cart if the specific product is added into the cart. but when we remove the specific product from cart then free product is still there. i need to remove the free product from the caryt if the specific product is removed.
<script>
$(".rb-free").click(function(e){
rbaddItemToCart();
});
$(".rb-free-c").click(function(e){
rbaddItemToCart();
});
function rbaddItemToCart(){
$.ajax({
type: 'POST',
url: '/cart/add.js',
async: false,
data: {
quantity: '1',
id: '44518734987569'
},
success: function (data) {
console.log('atc success: '+1 + id);
}
});
}
</script>
<div class="actions">
<div class="action-list addtocart">
<div class="button-wrapper">
{%- if product.available -%}
<div class="button-wrapper-content">
<button type="submit" name="add" class="btn-cart add-to-cart bordered uppercase {% **if product.handle == 'white-heat-ultra-burn' %} rb-free {% endif %}**">
<span>{{ 'products.product.add_to_cart' | t }}</span>
</button>
<!--<p>we’ll supply – will go</p>-->
</div>
{%- else -%}
<div class="button-wrapper-content">
<button href="javascript:;" class="btn-cart add-to-cart" disabled="disabled">
<span>{{ 'products.product.sold_out' | t }}</span>
</button>
</div>
{%- endif -%}
</div>
</div>
<div class="action-list wishlist">
{% include 'wishlist-item' %}
</div>
</div>

Related

Broken HTML has been detected in theme's sections/main-cart-footer.liquid

I have an error message in my Shopify store on the cart page. HTML error found Broken HTML has been detected in your theme's sections/main-cart-footer.liquid(opens a new window)file. Check that there are no missing or extra HTML tags present. See code below, can anyone help me address the errors and how to fix them.
{{ 'component-cart.css' | asset_url | stylesheet_tag }}
{{ 'component-totals.css' | asset_url | stylesheet_tag }}
{{ 'component-price.css' | asset_url | stylesheet_tag }}
{{ 'component-discounts.css' | asset_url | stylesheet_tag }}
<div class="page-width{% if cart == empty %} is-empty{% endif %}" id="main-cart-footer" data-id="{{ section.id }}">
<div>
<div class="cart__footer">
{%- if section.settings.show_cart_note -%}
<cart-note class="cart__note field">
<label for="Cart-note">{{ 'sections.cart.note' | t }}</label>
<textarea class="text-area text-area--resize-vertical field__input" name="note" form="cart" id="Cart-note" placeholder="{{ 'sections.cart.note' | t }}">{{ cart.note }}</textarea>
</cart-note>
{%- endif -%}
<div class="cart__blocks">
{% for block in section.blocks %}
{%- case block.type -%}
{%- when '#app' -%}
{% render block %}
{%- when 'subtotal' -%}
<div class="js-contents" {{ block.shopify_attributes }}>
<div class="totals">
<div>
<h3 class="totals__subtotal">{{ 'sections.cart.subtotal' | t }}</h3>
<p class="totals__subtotal-value"><span class="csapps-cart-original-total">{{ cart.total_price | money_with_currency }}</span></p>
</div>
<div data-tbnadhide='NO_DISCOUNT' style='display:none;'>
<h3 class="totals__subtotal">Discount</h3>
<p class="totals__subtotal-value"><span class="csapps-cart-original-total">-<span data-tbnadfield='CART_DISCOUNT'></span></span></p>
</div>
<div data-tbnadhide='NO_DISCOUNT' style='display:none;'>
<h3 class="totals__subtotal">Total</h3>
<p class="totals__subtotal-value"><span class="csapps-cart-original-total"><span data-tbnadfield='CART_TOTAL' class='ymq_cart_total_price'></span></span></p>
</div>
<div>
{%- if cart.cart_level_discount_applications.size > 0 -%}
<ul class="discounts list-unstyled" role="list" aria-label="{{ 'customer.order.discount' | t }}">
{%- for discount in cart.cart_level_discount_applications -%}
<li class="discounts__discount discounts__discount--end">
{%- render 'icon-discount' -%}
{{ discount.title }}
(-{{ discount.total_allocated_amount | money }})
</li>
{%- endfor -%}
</ul>
{%- endif -%}
</div>
<small class="tax-note caption-large rte">
{%- if cart.taxes_included and shop.shipping_policy.body != blank -%}
{{ 'sections.cart.taxes_included_and_shipping_policy_html' | t: link: shop.shipping_policy.url }}
{%- elsif cart.taxes_included -%}
{{ 'sections.cart.taxes_included_but_shipping_at_checkout' | t }}
{%- elsif shop.shipping_policy.body != blank -%}
{{ 'sections.cart.taxes_and_shipping_policy_at_checkout_html' | t: link: shop.shipping_policy.url }}
{%- else -%}
{{ 'sections.cart.taxes_and_shipping_at_checkout' | t }}
{%- endif -%}
</small>
</div>
{%- else -%}
<div class="cart__ctas" {{ block.shopify_attributes }}>
<noscript>
<button type="submit" class="cart__update-button button button--secondary" form="cart">
{{ 'sections.cart.update' | t }}
</button>
</noscript>
<button type="submit" id="checkout" class="cart__checkout-button button" name="checkout"{% if cart == empty %} disabled{% endif %} form="cart">
{{ 'sections.cart.checkout' | t }}
</button>
</div>
{%- if additional_checkout_buttons -%}
<div class="cart__dynamic-checkout-buttons additional-checkout-buttons">
{{ content_for_additional_checkout_buttons }}
</div>
{%- endif -%}
{%- endcase -%}
{% endfor %}
<div id="cart-errors"></div>
</div>
</div>
</div>
</div>
{% javascript %}
class CartNote extends HTMLElement {
constructor() {
super();
this.addEventListener('change', debounce((event) => {
const body = JSON.stringify({ note: event.target.value });
fetch(`${routes.cart_update_url}`, {...fetchConfig(), ...{ body }});
}, 300))
}
}
customElements.define('cart-note', CartNote);
{% endjavascript %}
<script>
document.addEventListener('DOMContentLoaded', function() {
function isIE() {
const ua = window.navigator.userAgent;
const msie = ua.indexOf('MSIE ');
const trident = ua.indexOf('Trident/');
return (msie > 0 || trident > 0);
}
if (!isIE()) return;
const cartSubmitInput = document.createElement('input');
cartSubmitInput.setAttribute('name', 'checkout');
cartSubmitInput.setAttribute('type', 'hidden');
document.querySelector('#cart').appendChild(cartSubmitInput);
document.querySelector('#checkout').addEventListener('click', function(event) {
document.querySelector('#cart').submit();
});
});
</script>
{% schema %}
{
"name": "t:sections.main-cart-footer.name",
"class": "cart__footer-wrapper",
"settings": [
{
"type": "checkbox",
"id": "show_cart_note",
"default": false,
"label": "t:sections.main-cart-footer.settings.show_cart_note.label"
}
],
"blocks": [
{
"type": "subtotal",
"name": "t:sections.main-cart-footer.blocks.subtotal.name",
"limit": 1
},
{
"type": "buttons",
"name": "t:sections.main-cart-footer.blocks.buttons.name",
"limit": 1
},
{
"type": "#app"
}
]
}
{% endschema %}
{% comment %}<!-- ymq option done -->{% endcomment %}
<script id="docapp-shipping-speedup" defer="defer">
(() => { if (!document.documentElement.innerHTML.includes('\\/shop' + '\\/js' + '\\/cart-shipping-calculator-pro.min.js') || window.cartShippingCalculatorProAppLoaded) return; let script = document.createElement('script'); script.src = "https://d1an1e2qw504lz.cloudfront.net/shop/js/cart-shipping-calculator-pro.min.js?shop=texaslonestartamales.myshopify.com"; document.getElementById('docapp-shipping-speedup').after(script); })();
</script>
<script id="docapp-shipping-speedup">
(() => { if (!document.documentElement.innerHTML.includes('\\/shop' + '\\/js' + '\\/cart-shipping-calculator-pro.min.js') || window.cartShippingCalculatorProAppLoaded) return; let script = document.createElement('script'); script.src = "https://d1an1e2qw504lz.cloudfront.net/shop/js/cart-shipping-calculator-pro.min.js?shop=texaslonestartamales.myshopify.com"; document.getElementById('docapp-shipping-speedup').after(script); })();
</script>

Shopify Ajax Update Cart

I want to be able to update my cart when I click on the increase button without having to click update button
Here is my script
<script>
let classlist = []
let val = document.querySelector('.qty-select')
let classes = document.getElementsByClassName('val')
for (var i=0; i<classes.length; i++) {
classlist.push(classes[i].innerText)
}
let lineclasses = classlist.join(", ")
val.onclick = function() {
jQuery.post('/cart/update.js', {updates: [lineclasses]});
console.log('dfdfdfd')
}
</script>
Here is my Liquid
{% for item in cart.items %}
<div class="product row">
<div class="col-lg-2 col-md-3 col-sm-4">
<img src="{{ item | img_url: 'medium' }}" />
</div>
<div class="col-lg-8 col-md-8 col-sm-7 product-info">
<div class="product-title">
{{ item.product.title }}
<span class="price right"><b>{{ item.price | money }}</b></span>
</div>
<div class="qty-select">
<input type="number" hidden="hidden" name="updates[]" id="updates_{{ item.key }}" class="qty"
value="{{ item.quantity }}" min="0" />
<span class="val">{{ item.quantity }}</span>
</div>
</div>
<div class="col-lg-2 col-md-1 col-sm-1 text-right remove">
<a aria-label="Remove {{ item.variant.title }}"
href="/cart/change?line={{ forloop.index }}&quantity=0"><i class="fas fa-times"></i></a>
</div>
</div>
{% endfor %}
I have tried this, but its not working

Multi file uploader in Shopify Debut theme

I'm customizing my page to upload multiple files (photos). This is the code that I have so far and according to this link it should work:
https://shopify.dev/tutorials/customize-theme-get-customization-information-for-products
in the link go to "Allow file uploads" if you want to check.
{% form 'product', product, class:form_classes, data-product-form: '', enctype:"multipart/form-data" %}
{% unless product.has_only_default_variant %}
<div class="product-form__controls-group">
{% for option in product.options_with_values %}
<div class="selector-wrapper js product-form__item">
<select class="single-option-selector single-option-selector-{{ section.id }} product-form__input"
id="SingleOptionSelector-{{ forloop.index0 }}"
data-index="option{{ forloop.index }}"
>
{% for value in option.values %}
<option value="{{ value | escape }}"{% if option.selected_value == value %} selected="selected"{% endif %}>{{ value }}</option>
{% endfor %}
</select>
</div>
{% endfor %}
</div>
{% endunless %}
<select name="id" id="ProductSelect-{{ section.id }}" class="product-form__variants no-js">
{% for variant in product.variants %}
<option value="{{ variant.id }}"
{%- if variant == current_variant %} selected="selected" {%- endif -%}
>
{{ variant.title }} {%- if variant.available == false %} - {{ 'products.product.sold_out' | t }}{% endif %}
</option>
{% endfor %}
</select>
{% if section.settings.show_quantity_selector %}
{% comment %}
<div class="product-form__controls-group">
<div class="product-form__item">
<input type="number" id="Quantity-{{ section.id }}"
name="quantity" value="1" min="1" pattern="[0-9]*"
class="product-form__input product-form__input--quantity" data-quantity-input
>
</div>
</div>
<div class="qtydiv">
{% comment %}<label for="Quantity" class="quantity-selector">Quantity</label>{% endcomment %}
<div class="qtybox">
<span class="btnqty qtyminus icon icon-minus">-</span>
<input type="text" id="quantity" name="quantity" value="1" min="1" class="quantity-selector quantity-input" readonly="">
<span class="btnqty qtyplus icon icon-plus">+</span>
</div>
</div>
{% endcomment %}
{% endif %}
<div class="product-form__error-message-wrapper product-form__error-message-wrapper--hidden{% if section.settings.enable_payment_button %} product-form__error-message-wrapper--has-payment-button{% endif %}"
data-error-message-wrapper
role="alert"
>
<span class="visually-hidden">{{ 'general.accessibility.error' | t }} </span>
{% include 'icon-error' %}
<span class="product-form__error-message" data-error-message>{{ 'products.product.quantity_minimum_message' | t }}</span>
</div>
<div class="product-form__controls-group product-form__controls-group--submit">
<div class="qtydiv">
{% comment %}<label for="Quantity" class="quantity-selector">Quantity</label>{% endcomment %}
<div class="qtybox">
<span class="btnqty qtyminus icon icon-minus">-</span>
<input type="text" id="quantity" name="quantity" value="1" min="1" class="quantity-selector quantity-input" readonly="">
<span class="btnqty qtyplus icon icon-plus">+</span>
</div>
</div>
<div class="product-form__item product-form__item--submit
{%- if section.settings.enable_payment_button %} product-form__item--payment-button {%- endif -%}
{%- if product.has_only_default_variant %} product-form__item--no-variants {%- endif -%}"
>
<button type="submit" name="add"
{% unless current_variant.available %} aria-disabled="true"{% endunless %}
aria-label="{% unless current_variant.available %}{{ 'products.product.sold_out' | t }}{% else %}{{ 'products.product.add_to_cart' | t }}{% endunless %}"
class="btn product-form__cart-submit{% if section.settings.enable_payment_button %} btn--secondary-accent{% endif %}"
data-add-to-cart>
<span data-add-to-cart-text>
{% unless current_variant.available %}
{{ 'products.product.sold_out' | t }}
{% else %}
{{ 'products.product.add_to_cart' | t }}
{% endunless %}
</span>
<span class="hide" data-loader>
{% include 'icon-spinner' %}
</span>
</button>
{% if section.settings.enable_payment_button %}
{{ form | payment_button }}
{% endif %}
</div>
<input required class="required product-form__input" id="photo" type="file" name="properties[Photo]" multiple>
</div>
</div>
{% endform %}
This is my form that according to the link must have the attribute
enctype = "multipart / form-data".
At the bottom of the form it is in input type = "file".
<input required class="required product-form__input" id="photo" type="file" name="properties[Photo]" multiple>
And this is the code in the cart-template.liquid.
<div class="list-view-item__title">
<a href="{{ item.url }}" class="cart__product-title" data-cart-item-title>
{{ item.product.title }}<br>
{% assign property_size = item.properties | size %}
{% if property_size > 0 %}
{% for p in item.properties %}
{{ item.properties.count }}
{% assign first_character_in_key = p.first | truncate: 1, '' %}
{% unless p.last == blank or first_character_in_key == '_' %}
{{ p.first }}:
{% if p.last contains '/uploads/' %}
<a class="lightbox" href="{{ p.last }}">{{ property_size }}</a>
{% else %}
{{ p.last }}
{% endif %}
<br>
{% endunless %}
{% endfor %}
{% endif %}
</a>
</div>
The problem is the property_size variable gets value one even if I upload two or more images, when in fact I should return the amount of properties that the item has.
Can anyone help me please? What I am doing wrong?
The Debut theme probably has changed since this tutorial was uploaded, and since it is not supported, probably won't be updated.
If you add a type="text" input instead of a type="file" the property gets added as expected. This happens because the _initAddToCart function (assets/theme.js line 6447) gets the form HTML element and pass it along to another function.
var $data = $(this.selectors.productForm, this.$container);
this._addItemToCart($data);
Then in the _addItemToCart function (assets/theme.js line 6513), the form is serialized to a string:
var params = {
url: '/cart/add.js',
data: $(data).serialize(),
dataType: 'json',
};
$.post(params).done(...
This function will ignore the file inputs, as explained in the jQuery documentation:
Data from file select elements is not serialized.
To send the file, the FormData browser API can be used. But to use it with the jQuery AJAX call, some properties must be set:
var params = {
url: '/cart/add.js',
// data: $(data).serialize(),
dataType: 'json',
// Disable the jQuery data processing, and send the FormData object
contentType: false,
processData: false,
data: new FormData($(data).get()[0])
};
$.post(params).done(...
However, since the HTML file <input> has name="properties[Photo]", only the last of the uploaded files will be added to the cart item's Photo property.
I tried with name="properties[Photo][]", but the cart/add.js call only returns an error 500 with the message "Internal Server Error".
So to upload multiple files you could add some custom code to the _addItemToCart function, to get each File from the <input> and add to the FormData with a different key for each file.

Shopify Store - Variant Not adding To Cart

I cannot get my swatch variants to change what product is being added to the cart. No matter what I add it is adding the 'emerson' product. Here is my product.liquid code. I am also using the swatches app.
{% include 'bold-product' with product, hide_action: 'break' %}{% if bold_hidden_product %}{% break %}{%endif %}
<!-- Bold D&H //product -->
{% if product.metafields.inventory.ShappifyHidden == "true" %}
Product is not available
{% break %}{% endif %}
<!-- // end product D&H -->
{% include 'shappify-bdl-no-select' %}
<!-- Bold: Discount D&H -->
{% if product.metafields.inventory.ShappifyHidden == "true" %}
Product is not available
{% else %}
<div id="col-main" class="span12 bva">
<div itemscope itemtype="http://schema.org/Product" class="product-scope">
<meta itemprop="url" content="{{ shop.url }}{{ product.url }}" />
<meta itemprop="name" content="{{ product.title }}" />
<!-- NEW -->
<div class="gallery span8">
<span class=”desc”> {{ product.metafields.lifestyle.gallery }} </span>
</div>
<div class="product-top bva span9">
<div id="product-image" class="product-image bva">
<div id="product" class="row-fluid clearfix">
<div id="product-image" class="span12 product-image">
<div class="product-image-wrapper bva">
<div class="product-thumb-slides">
{% for variant in product.variants %}
{% include 'bold-hidden-variants' with variant, bold_loop: 'loop' %}
{% assign image_variant_available = true %}
{% assign image = variant.image %}
{% assign index = forloop.index | minus: 1 %}
<div data-swatch="{{ image.alt | downcase | handleize }}" data-swatch-color="{{ image.alt }}" data-index="{{ index }}" data-variant-id="{{ variant.id }}">
<img src="{{ image | img_url: 'compact' }}" alt="{% if image.alt contains 'youtube' %}{{ product.title }}{% else %}{{ image.alt | escape }}{% endif %}" />
</div>
{% endfor %}
</div>
<div id="product-image" class="span12 product-image">
<div class="product-image-wrapper">
<a target="_blank" href="{{ product.featured_image | product_img_url: 'original' }}" class="main-image{% if settings.main_image_display == 'zoom' or settings.main_image_display == 'both' %} elevatezoom{% endif %}{% if settings.main_image_display == 'lightbox' %} fancybox{% endif %}">
<img itemprop="image"id="main-image" class="img-zoom img-responsive image-fly" src="{% if shappify_bdl_options_count > 1 %}{{ product.featured_image | product_img_url: 'grande' }}{% else %}{{ product.featured_image | product_img_url: 'original' }}{% endif %}" alt="{{ product.title | escape }}" />
<span class="main-image-bg"></span>
</a>
{% if product.images.size > 1 %}
{% if settings.viewmore_image_display == 'carousel' %}
<div class="gallery_main_wrapper">
{% endif %}
<div id="gallery_main" class="product-image-thumb {% if settings.viewmore_image_display == 'scroll' %}scroll scroll-mini{% endif %} clearfix">
{% for image in product.images %}
{% assign image_variant_available = false %}
{% if image.variants.size > 0 %}
{% for variant in image.variants %}
{% if variant.available %}
{% assign image_variant_available = true %}
{% endif %}
{% endfor %}
{% else %}
{% assign image_variant_available = true %}
{% endif %}
{% if image_variant_available %}
{% if image.alt contains '-alt' %}
{% else %}
<a class="image-thumb{% if forloop.index == 1 %} active{% endif %}" href="{{ image | product_img_url: 'original' }}" data-image-zoom="{{ image | product_img_url: 'original' }}" data-image="{{ image | product_img_url: 'original' }}"onclick="if($('.selector-wrapper .single-option-selector[data-option=\'option1\'] option[value=\'{{ image.alt | replace: "'", "\\'" }}\']').length > 0 && $('.selector-wrapper .single-option-selector[data-option=\'option1\']').val() != '{{ image.alt | replace: "'", "\\'" }}') $('.selector-wrapper .single-option-selector[data-option=\'option1\']').val('{{ image.alt | replace: "'", "\\'" }}'), $('.selector-wrapper .single-option-selector[data-option=\'option1\']').trigger('change');">
<img src="{{ image | product_img_url: 'small' }}" alt="{% if image.alt contains 'youtube' %}{{ product.title }}{% else %}{{ image.alt | escape }}{% endif %}" />
</a>
{% endif %}
{% endif %}
{% endfor %}
{% for image in product.images %}
{% if image.alt contains 'youtube' %}
{% assign embed_url = image.alt %}
<div class="image-thumb-video play-icon">
<img src="{{ image | product_img_url: 'small' }}" alt="{{ product.title | escape }}" />
<a class="play-container fancy" href="{{ embed_url }}" title="{{ product.title }}">
{{ 'play-icon.svg' | asset_url | img_tag: 'Play Video', 'play-image' }}
</a>
<p>WATCH<br>VIDEO</p>
</div>
{% endif %}
{% endfor %}
</div>
{% if settings.viewmore_image_display == 'carousel' %}
</div>
{% endif %}
{% endif %}
</div>
{% if settings.tweet_code == 'below' %}
{% if settings.tweet_code_page != empty %}
<a id="tweet_code" class="btn btn-2" href="{{pages[settings.tweet_code_page].url}}"><i class="icon-hand-right"></i> {{settings.tweet_code_discount_button}}</a>
{% endif %}
{% endif %}
</div>
<script>
jQuery(document).ready(function($){
$('.product-thumb-slides').slick({
slidesToShow: 4,
slidesToScroll: 1,
asNavFor: '.product-slick-gallery',
dots: false,
arrows: true,
focusOnSelect: true,
vertical: true,
centerMode: false,
infintie: false,
nextArrow: '<i class="fa fa-chevron-down slick-next"></i>',
prevArrow: '<i class="fa fa-chevron-up slick-prev"></i>',
});
$('.product-slick-gallery').slick({
arrows: false,
dots : false,
asNavFor: '.product-thumb-slides'
});
$('.quantity').spinner({
min: 1,
change: function(event,ui){
$(this).attr("value", this.value);
//$('.add-cart').attr('data-quantity', this.value);
}
});
$('.product-thumb-slides').on('beforeChange', function(event, slick, currentSlide, nextSlide){
var variantID = $('.product-thumb-slides .slick-slide[data-index="'+nextSlide+'"]').data('variant-id');
var swatch_color = $('.product-thumb-slides .slick-slide[data-index="'+nextSlide+'"]').data('swatch-color');
// console.log(variantID);
//$('.add-cart').attr('data-variant-id', variantID);
$('.hidden-variant-field').attr('value', variantID);
$('.color-name-dynaimc').html(swatch_color);
var $swatch = $('.swatch-element[data-variant-id="'+variantID+'"]');
// console.log($swatch);
if($swatch.hasClass('soldout')){
$('.add-cart').addClass('out-of-stock');
$('.cart-button').html('SOLD OUT');
}else{
$('.add-cart').removeClass('out-of-stock');
$('.cart-button').html('ADD TO CART');
}
});
var productDesc = $('.product-info .product-description p:nth-child(2)').html();
$('.product-info .product-description p:nth-child(2)').html('<strong>DESCRIPTION</strong>'+productDesc);
$('.color-name-dynaimc').html( $('.product-thumb-slides .slick-slide[data-index="0"]').data('swatch-color') );
//$('.add-cart').attr('data-variant-id', $('.product-thumb-slides .slick-slide[data-index="0"]').data('variant-id') );
$('.hidden-variant-field').attr('value', $('.product-thumb-slides .slick-slide[data-index="0"]').data('variant-id') );
// $('.add-cart').click(function(event){
// event.preventDefault();
// var variantID = $(this).data('variant-id');
// var quantity = $(this).data('quantity');
// CartJS.addItem( variantID, quantity);
// setTimeout(function(){
// location.reload();
// },500);
// });
});
</script>
</div>
</div>
</div>
<div class="product-share">
SHARE THIS PRODUCT:
<img src="{{ 'facebook-logo-01.png' | asset_url }}" class="fa fa-facebook social-sharing-icon" style="max-width: 30px" data-network="facebook">
<img src="{{ 'twitter-logo-silhouette-01.png' | asset_url }}" class="fa fa-twitter social-sharing-icon" style="max-width: 30px" data-network="twitter">
<img src="{{ 'pinterest-logo-button-01.png' | asset_url }}" class="fa fa-pinterest social-sharing-icon" style="max-width: 30px" data-network="pinterest">
</div>
</div>
<div class="product-details bva">
<div class="titles">
<div itemprop="name" class="product-name">
<h1>{{ product.title }} <span class="mobile-only">- <span class="color-name-dynaimc"></span></span></h1>
</div>
<div class="detail-price" itemprop="price">
<span class="price">{{ product.price | money }}</span>
</div>
</div>
<div class="variants-wrapper clearfix{% if hide_default_title %} hide{% endif %}">
<select id="product-select-{{ product.id }}" name="id">
{% for variant in product.variants %}
{% include 'bold-hidden-variants' with variant, bold_loop: 'loop' %}
{% if variant.metafields.shappify_bundle.is_bundle == "true" %}{% else %}
<option value="{{ variant.id }}">{{ variant.title | escape }} - {{ variant.price | money }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<form action="/cart/add" method="post" class="product-actions variants " enctype="multipart/form-data">
<div id="product-actions-{{ product.id }}" class="options qty-cart">
<!--<input id="quantity" type="number" name="quantity" value="1" min="1" class="span4 item-quantity" />-->
<div class="input-box">
<input id="quantity" type="text" name="quantity" class="quantity item-quantity" value="1" min="1" />
</div>
<div class="action-wrapper product add-cart">
<div class="product-wait"></div>
<input type="hidden" name="id" value="{{ variant.id }}" class="hidden-variant-field"/>
<button class="cart-button {% if variant.inventory_quantity < 0 %}out-of-stock{% endif %}" unbxdattr="AddToCart" unbxdparam_sku="{{product.id}}" data-parent=".product-information" type="submit" name="add">ADD TO CART</button>
</div>
</div>
</form>
{% unless bundle_loaded == 'true' %}
{% include 'shappify-bdl-load-bundle' %}
{% assign bundle_loaded = 'true' %}
{% endunless %}
<div class="rumepoints">
<strong>You Will Earn:</strong> <span class=”desc”> {{ product.metafields.totes.rumepoints }} </span> <u>RuMe Rewards Points</u> for this item
</div>
</div>
</div>
</div>
</div>
<div class="descriptionusesfeatures">
<div class="product-description">
<strong>DESCRIPTION</strong><br><br>
{{ product.description }}
</div>
<div class="description-right">
<div class="usesforhtml"><strong>USES FOR:</strong><br><br>
<span class=”desc”> {{ product.metafields.usesfor.usesforhtml }} </span>
</div>
<br>
<div class="productfeatures"><strong>FEATURES:</strong><br><br>
<span class=”desc”> {{ product.metafields.features.productfeatures }} </span>
</div>
</div>
</div>
<!-- END -->
{% if settings.product_description_show == 'below' %}
<div itemprop="description" class="description text-left">
<h1>{{ product.title }}</h1>
<!-- {{ product.description }} Replaced with shortcodes version,below -->
{% include 'shortcodes' with product.description %}
</div>
{% endif %}
{% if settings.reviews_enable %}
<div id="shopify-product-reviews" data-id="{{product.id}}">{{ product.metafields.spr.reviews }}</div>
{% endif %}
</div>
{% include 'related-products' %}
<!-- yotpo -->
<div class="yotpo yotpo-main-widget"
data-product-id="{{ product.id }}"
data-name="{{ product.title | escape }}"
data-url="{{ shop.url }}{{ product.url }}"
data-image-url="{{ product.featured_image | product_img_url: "large" |replace: '?', '%3F' | replace: '&','%26'}}"
data-description="{{ product.description | escape }}">
</div>
<!-- yotpo -->
</div>
<!-- end slider wrapper -—>
<!-- Bold: Discount D&H -->
{% endif %}
<script type="text/javascript">
(function e(){var e=document.createElement("script");e.type="text/javascript",e.async=true,e.src="//staticw2.yotpo.com/V3G5rrxyCEg9hXApffAzbDMC6CsghmTdUpbf8D2z/widget.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})();
</script>
<script type="text/javascript">
$("a.fancy").click(function() {
$.fancybox({
'padding' : 40,
'autoScale' : false,
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'title' : this.title,
'width' : 1280,
'height' : 720,
'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '?autoplay=1',
'type' : 'swf', // <--add a comma here
'swf' : {'allowfullscreen':'true'} // <-- flashvars here
});
return false;
});
</script>
<script>
// To change what your customers would see if they try to
// add to cart without completing an option, edit the yellow text enclosed within the quotation marks.
var errorMessages = {
for_text_inputs : "Please add your personalized text before adding to cart.",
for_number_inputs: "Please enter a custom quantity.",
for_checkboxes : "Please select your options before adding to cart",
for_dropdowns : "Please select an option before adding to cart"
};
jQuery("form[action='/cart/add'] [type=submit]").on("click", function(e) {
if (
window.Shoppad &&
window.Shoppad.apps &&
window.Shoppad.apps.customizery &&
window.Shoppad.apps.customizery.overrideDeprecatedValidation
) return true;
$io = $('#infiniteoptions-container');
var invalidTextInputs = $io.find("input[type=text][required], textarea").filter(function (idx, el) {
return $(el).val() === '';
});
var invalidNumberInputs = $io.find('input[type=number][required]').filter(function (idx, el) {
return $(el).val() === '';
});
var invalidFieldSets = $io.find('fieldset[data-required=true]').filter(function (idx, fieldSet) {
if ($(fieldSet).find('input[type=checkbox]').length === 0) {
return false;
} else {
return $(fieldSet).find('input[type=checkbox]').filter(function (idx, el) {
return el.checked === true;
}).length === 0;
}
});
var invalidDropdowns = $io.find('select[required]').filter(function (idx, select) {
return !select.selectedOptions[0] || select.selectedOptions[0].disabled === true;
});
var onFail = function (messageType) {
e.stopImmediatePropagation();
alert( errorMessages[messageType] );
return false;
};
if (invalidTextInputs.length > 0) {
return onFail( 'for_text_inputs' );
} else if (invalidNumberInputs.length > 0) {
return onFail( 'for_number_inputs' );
} else if (invalidFieldSets.length > 0) {
return onFail( 'for_checkboxes' );
} else if (invalidDropdowns.length > 0) {
return onFail( 'for_dropdowns' );
} else {
return true;
}
});
</script>
{% include 'shappify-bdl-load-bundle' %}
<script type="text/javascript">
// initialize multi selector for product
jQuery(document).ready(function($){
/* selectCallback */
var selectOptionsCallback = function(variant, selector) {
var add_to_cart = '#add-to-cart';
var $price = '#purchase-' + selector.product.id.toString() + ' .detail-price';
if (variant && variant.available) {
// selected a valid variant
$(add_to_cart).removeClass('disabled').removeAttr('disabled'); // remove unavailable class from add-to-cart button, and re-enable button
if(variant.compare_at_price == null){
$($price).html('<span class="price">'+Shopify.formatMoney(variant.price, "{{shop.money_format}}")+'</span>');
{% if settings.show_multiple_currencies %}
/* Update currency */
currenciesCallbackSpecial('#product-information span.money');
{% endif %}
} else {
$($price).html('<del class="price_compare">' + Shopify.formatMoney(variant.compare_at_price, "{{shop.money_format}}") + '</del>' + '<span class="price_sale">'+Shopify.formatMoney(variant.price, "{{shop.money_format}}") + '</span>');
{% if settings.show_multiple_currencies %}
/* Update currency */
currenciesCallbackSpecial('#product-information span.money');
{% endif %}
}
} else {
$(add_to_cart).addClass('disabled').attr('disabled', 'disabled'); // set add-to-cart button to unavailable class and disable button
var message = variant ? "Sold Out" : "Unavailable";
$($price).html('<span class="unavailable">' + message + '</span>');
}
if (variant && variant.inventory_quantity && variant.inventory_management == 'shopify') {
jQuery("#stock").html(variant.inventory_quantity).parent().show();
}
else{
jQuery("#stock").parent().hide();
}
{% if settings.trans_product_sku %}
if (variant && variant.sku) {
jQuery("#sku").html(variant.sku).parent().show();
}
else{
jQuery("#sku").parent().hide();
}
{% endif %}
{% if settings.product_barcode_show %}
if (variant && variant.barcode) {
jQuery("#barcode").html(variant.barcode).parent().show();
}
else{
jQuery("#barcode").parent().hide();
}
{% endif %}
//Swapping images JS
$('.product-image-thumb img[alt="'+ $('.selector-wrapper .single-option-selector[data-option=\'option1\']').val() +'"]').first().parent().trigger('click');
};
new Shopify.OptionSelectors("product-select-{{ product.id }}", { product: {{ product | json | remove:'\u003E' | remove:'\u003C' | remove:'\u00a0' }}, onVariantSelected: selectOptionsCallback });
<!-- START Hide OOS Product Varients -->
{% if product.options.size == 1 %}
{% for variant in product.variants %}
{% include 'bold-hidden-variants' with variant, bold_loop: 'loop' %}
{% if variant.metafields.shappify_bundle.is_bundle == "true" %}{% else %}
{% unless variant.available %}
jQuery('.single-option-selector option').filter(function() { return jQuery(this).html() === {{ variant.title | json }}; }).remove();
{% endunless %}
{% endif %}
{% endfor %}
//jQuery('.single-option-selector').trigger('change');
{% endif %}
<!-- END Hide OOS Product Varients -->
// Add label if only one product option and it isn't 'Title'.
{% if product.options.size == 1 and product.options.first != 'Title' %}
$('#product-actions-{{ product.id }} .selector-wrapper:eq(0)').prepend('<label>{{ product.options.first }}</label>');
{% endif %}
// Auto-select first available variant on page load.
{% assign found_one_in_stock = false %}
{% for variant in product.variants %}
{% include 'bold-hidden-variants' with variant, bold_loop: 'loop' %}
{% if variant.metafields.shappify_bundle.is_bundle == "true" %}{% else %}
{% if variant.available and found_one_in_stock == false %}
{% assign found_one_in_stock = true %}
{% for option in product.options %}
$('.single-option-selector:eq({{ forloop.index0 }})').val({{ variant.options[forloop.index0] | json }}).trigger('change');
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
});
</script>
{% include 'windsor-product-tracking' %}Ò
This ended up being a javascript not being able to fire issue. We moved the script higher in the file and corrected the issue.

Why can't I search spaces in shopify what do I do?

UPDATE
Ok I know what the problem is, but not how to solve it.
vendor:cow horn OR title:cow horn doesn't work
title:cow horn OR vendor:cow horn does.
Spaces are causing the additional prefixes to break where "OR" isn't properly working in my search results.
vendor:cow OR title:cow works
But the moment I put a space in the search then the title won't be searched.
I have a search bar, and I set it to search for an items tag, vendor & title.
Problem is this code prevents me from being able to use spaces in my search term, and if I append "*" I'm unable to use ampersands. Here's the code.
<form method="get" action="/search" id="search-home">
<button type="submit" value="search"></button>
<input type="hidden" name="type" value="product" />
<input type="hidden" name="q" class="searchtext" />
<input type="text" name="original" placeholder="Search"/>
</form>
<script>
$(document).on('submit','#search-home',function(){
var searchtext = $('input[name="original"]').val();
$('.searchtext').val("vendor:"+searchtext+" OR tag:"+searchtext+" OR title:"+searchtext);
});
</script>
If you need to see the search.liquid here it is.
<div id="impact-grid-header" class="collections-page">
<h1 id="regular-title">Search Results for: "{{ search.terms[1] | replace: 'vendor:', '' | replace: 'tag:', '' | replace: 'title:', '' | replace: '*', '' | strip | escape}}"</h1>
</div>
<div id="product-content" class="full-bleed">
<div class="content">
{% paginate search.results by 20 %}
<!-- Begin collection info -->
<div class="row">
<!-- End sort collection -->
<div class="column inventory-items">
{% include 'search-bar' %}
<div id="inventory" class="span12 content-grid">
<!-- Begin no products -->
{% if search.results.size == 0 %}
<div class="row">
<div class="span12 expanded-message">
<p>That's a great idea but unfortunately we don't have that item.<br/>Try again?</p>
</div>
</div>
{% endif %}
<div class="row products">
{% for item in search.results limit: settings.pagination_limit %}
{% if item.variants.first.inventory_quantity >= 0 %}
<div class="item product" data-tags="{% for tag in item.tags %}{{ tag | downcase }}, {% endfor %}">
<a href="{{ item.url }}">
<div class="product-pic">
<div class="inner-pic">
<img src="{{ item.featured_image | product_img_url: 'large' }}" alt="{{ item.title | escape }}"/>
</div>
<!-- Box that appears upon hover -->
<div class="view-product bg-black">
<i class="icon-search"></i>
<span>View</span>
</div>
</div>
</a>
<div class="description">
<span class="product-name">{{ item.title }}</span>
<span class="brand">{{ item.vendor }}</span>
<span class="price">
{% if item.available %}
{% if item.compare_at_price_max > item.price %}
<del>{{ item.compare_at_price | money }}</del>
{% endif %}
{% if item.price_varies %}
<em>from</em>
{% endif %}
<span>{{ item.price | money }}</span>
{% else %}
<span>
{{ item.price | money }} Sold Out
</span>
{% endif %}
</span>
<span class="shopify-product-reviews-badge" data-id="{{ product.id }}"></span>
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% include 'pagination' %}
{% endpaginate %}
<!-- End no products -->
</div>
</div>
</div>
</div>