Advertisement
customfiy

Customify Infinity

Mar 6th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.65 KB | None | 0 0
  1. <div id="left-side"> {{ customify-widget }}</div>
  2. <div id="right-side">
  3. <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
  4. <link itemprop="availability" href="http://schema.org/InStock">
  5. <meta itemprop="priceCurrency" content="{{ shop.currency }}">
  6. <link itemprop="availability" href="http://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}">
  7. <h1 itemprop="name">{{ product.title }}</h1> {% assign form_grid = false %} {% if form_method == "standard" or product.variants.size == 1 %}
  8. <div class="customify-form-row"> <span id="ProductPrice" class="customify-price" itemprop="price" content="{{ product.price | divided_by: 100.00 }}"> <span id="variant_price" >{{ product.price | money }}</span> </span>{% if product.compare_at_price > product.price %} <span id="PriceA11y" class="visually-hidden">Price</span> <s id="compare_price" class="product-single__sale-price"> {{ product.compare_at_price_max | money }} </s> {% endif %}</div>
  9. <form name="customify_form" id="customify_form" action="/cart/add" method="post" enctype="multipart/form-data">
  10. <input type="file" id="customify-upload" style="display: none" />
  11. <input type="hidden" id="customify_id" name="properties[customify_id]" /> {% if product.variants.size == 1 %}
  12. <input type="hidden" value="{{ product.variants.first.id }}" name="id" />{% else %}
  13. <select name="id" id="productSelect" class="product-single__variants"> {% for variant in product.variants %} {% if variant.available %}
  14. <option data-sku="{{ variant.sku }}" value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money_with_currency }}</option>{% else %}
  15. <option disabled="disabled"> {{ variant.title }} - Sold Out</option> {% endif %} {% endfor %} </select>{% endif %}{{ product_color_grid }}{{ customify_text_widget }}
  16. <div class="customify-form-row">
  17. <div id="infiniteoptions-container"></div>
  18. <script type="text/javascript"> window.productJSON = window.productJSON || {{ product | json }};</script>
  19. </div>
  20. <div class="customify-form-row">
  21. <label for="Quantity">Quantity</label>
  22. <input type="number" id="Quantity" name="quantity" value="1" min="1" class="quantity-selector">
  23. </div>
  24. <div class="customify-form-row">
  25. <label id="note-label" for="note">Note</label>
  26. <textarea id="note" name="properties[customify_note]"></textarea>
  27. </div>
  28. <div class="customify-form-row">
  29. <button id="back-product" style="display: none; margin-right: 10px; " type="button" class="btn"> <span>&laquo; BACK</span> </button>
  30. <button type="submit" name="add" id="customify-addtocart" class="btn"> <span id="AddToCartText">ADD TO CART</span> </button>
  31. </div>
  32. </form>
  33. <div class="customify-form-row"> {{ product.description }}</div> {% else %} {% assign form_grid = true %}
  34. <div id="customify-variant-table">
  35. <input type="file" id="customify-upload" style="display: none" />{{ product_color_grid }}{{ customify_text_widget }}
  36. <table width="100%" border="0" cellspacing="0" cellpadding="0" name="id" style="display:block;!important">
  37. <tbody>
  38. <tr class="{% cycle 'rx','ry' %}">{% for option in product.options %}
  39. <th>{{ option }}</th> {% endfor %}
  40. <th scope="col" class="center">Price</th>
  41. <th scope="col" style="width: 80px;" class="textright">Quantity</th>
  42. </tr> {% for variant in product.variants %} {% if variant.available %}
  43. <tr class="{% cycle 'xx','yy' %}" id="variant_tr-{{ variant.id }}"> {% for option in product.options %}
  44. <td class='text'>{{ variant.options[forloop.index0] }}</td> {% endfor %}
  45. <td value="{{ variant.id }}" title="" class="center">{{ variant.price | money }} {% if variant.compare_at_price > variant.price %} <del>{{ variant.compare_at_price | money }}</del>{% endif %}</td>
  46. <td> {% if variant.available %}
  47. <input data-idx="{{ variant.id }}" class='qty_input' type="text" value="0" name="qty_{{variant.id}}" id="qty_{{ variant.id}}" /> {% else %} Sold {% endif %}</td>
  48. </tr> {% endif %} {% endfor %}</tbody>
  49. </table>
  50. <div class="msg-info" style="display: none; padding: 10px 0px;"></div>
  51. </div>
  52. <div class="customify-form-row">
  53. <button id="back-product" style="display: none; margin-right: 10px; " type="button" class="btn"> <span>&laquo; BACK</span> </button>
  54. <button type="submit" name="add" id="customify-addtocart" class="btn"> <span id="AddToCartText">ADD TO CART</span> </button>
  55. </div> {% endif %}</div>
  56. </div>{% if form_grid %}
  57. <br />
  58. <div class="customify-form-row"> {{ product.description }}</div>
  59. <script type="text/javascript">
  60. var the_form = $("#customify-variant-table");
  61. success_div = the_form.find(".msg-info");
  62.  
  63. function add_to_cart_mass(t) {
  64. Shopify.queue = [];
  65. var i = 0;
  66. the_form.find('.qty_input').each(function() {
  67. idx = $(this).attr('data-idx');
  68. qty = $(this).val() * 1;
  69. if (qty > 0) {
  70. Shopify.queue.push({
  71. variant_id: idx,
  72. quantity: qty,
  73. properties: {
  74. 'customify_id': t
  75. }
  76. });
  77. i++;
  78. }
  79. });
  80. if (i > 0) Shopify.moveAlong();
  81. }
  82. Shopify.moveAlong = function() {
  83. if (Shopify.queue.length) {
  84. $('#customify-addtocart').attr('disable', true).html("<span id='AddToCartText'>Processing..</span>");
  85. var request = Shopify.queue.shift();
  86. Shopify.addItem(request.variant_id, request.quantity, request.properties, Shopify.moveAlong);
  87. } else {
  88. success_div.html('<span>Item(s) Added to the Cart!</span> <a href="/cart">View cart</a>').fadeIn(300).delay(7000).fadeOut(300);
  89. $('#customify-addtocart').attr('disable', false).html("<span id='AddToCartText'>" + add_to_cart_text + "</span>");
  90. window.location = "/cart"
  91. }
  92. };
  93. Shopify.addItem = function(id, qty, properties, callback) {
  94. var params = {
  95. quantity: qty,
  96. id: id
  97. };
  98. if (properties != false) {
  99. params.properties = properties;
  100. }
  101. $.ajax({
  102. type: 'POST',
  103. url: '/cart/add.js',
  104. dataType: 'json',
  105. data: params,
  106. success: function() {
  107. if (typeof callback === 'function') {
  108. callback();
  109. }
  110. },
  111. error: function() {}
  112. });
  113. }
  114. </script> {% else %} {{ "option_selection.js" | shopify_asset_url | script_tag }}
  115. <script type="text/javascript">
  116. $(document).ready(function() {
  117. function getUrlParams(e, n) {
  118. n || (n = window.location.href), e = e.replace(/[\[\]]/g, "\$&");
  119. var r = new RegExp("[?&]" + e + "(=([^&#]*)|&|#|$)"),
  120. a = r.exec(n);
  121. return a ? a[2] ? decodeURIComponent(a[2].replace(/\+/g, " ")) : "" : null
  122. }
  123. var variant_id = getUrlParams("variant");
  124. $("select[name='id']").val(variant_id);
  125. console.log("script proceed");
  126. var selectCallback2 = function(variant, selector) {
  127. $("#variant_price").html(Shopify.formatMoney(variant.price, "{{ shop.money_with_currency_format }}"));
  128. $("#compare_price").html(Shopify.formatMoney(variant.compare_at_price, "{{ shop.money_with_currency_format }}"));
  129. if (variant.inventory_management == "shopify" && variant.inventory_policy == "deny" && variant.old_inventory_quantity == 0) {
  130. $("#customify-addtocart").prop("disabled", true);
  131. $("#recreation-button").hide();
  132. $("#AddToCartText").text("SOLD OUT");
  133. } else {
  134. $("#recreation-button").show();
  135. $("#customify-addtocart").prop("disabled", false);
  136. }
  137. };
  138. jQuery(function($) {
  139. new Shopify.OptionSelectors("productSelect", {
  140. product: {{ product | json }},
  141. onVariantSelected: selectCallback2,
  142. enableHistoryState: true
  143. }); {{ %
  144. if product.options.size == 1 and product.options.first != "Title" %
  145. }}$(".selector-wrapper:eq(0)").prepend('<label for="productSelect-option-0">{{ product.options.first | escape }}</label>'); {{ % endif %
  146. }} {{ %
  147. if product.variants.size == 1 and product.variants.first.title contains "Default" %
  148. }}
  149. $(".selector-wrapper").hide(); {{ % endif %
  150. }}
  151. });
  152. });
  153.  
  154. function add_to_cart(t) {
  155. document.getElementById("customify_id").value = t;
  156. document.getElementById("customify_form").submit();
  157. }
  158. $(window).on("load", function() {
  159. $("#customify_form div").removeClass("selectreplace");
  160. });
  161. </script> {% endif %}
  162. <script type="text/javascript">
  163. $(document).ready(function() {
  164. if ($("#main-container").parents(".customify-back").length > 0) {
  165. $("#back-product").show().attr("onclick", "window.location='{{ product.url }}'");
  166. }
  167. });
  168. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement