Advertisement
Guest User

widget

a guest
Feb 23rd, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.50 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>
  8. {% assign form_grid = false %}
  9. {% if form_method == "standard" or product.variants.size == 1 %}
  10. <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>
  11. {% 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>
  12. <form name="customify_form" id="customify_form" action="/cart/add" method="post" enctype="multipart/form-data">
  13. <input type="file" id="customify-upload" style="display: none" />
  14. <input type="hidden" id="customify_id" name="properties[customify_id]" /> {% if product.variants.size == 1 %}
  15. <input type="hidden" value="{{ product.variants.first.id }}" name="id" />{% else %}
  16. <select name="id" id="productSelect" class="product-single__variants"> {% for variant in product.variants %} {% if variant.available %}
  17. <option data-sku="{{ variant.sku }}" value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money_with_currency }}</option>{% else %}
  18. <option disabled="disabled"> {{ variant.title }} - Sold Out</option> {% endif %} {% endfor %} </select>{% endif %}{{ product_color_grid }}{{ customify_text_widget }}
  19. <div class="customify-form-row">
  20. <label for="Quantity">Quantity</label>
  21. <input type="number" id="Quantity" name="quantity" value="1" min="1" class="quantity-selector">
  22. </div>
  23. <div class="customify-form-row">
  24. <label id="note-label" for="note">Note</label>
  25. <textarea id="note" name="properties[customify_note]"></textarea>
  26. </div>
  27. <div class="customify-form-row">
  28. <button id="back-product" style="display: none; margin-right: 10px; " type="button" class="btn"> <span>&laquo; BACK</span> </button>
  29. <button type="submit" name="add" id="customify-addtocart" class="btn"> <span id="AddToCartText">ADD TO CART</span> </button>
  30. </div>
  31. </form>
  32. <div class="customify-form-row"> {{ product.description }}</div>
  33. {% else %}
  34. {% assign form_grid = true %}
  35. <div id="customify-variant-table">
  36. <input type="file" id="customify-upload" style="display: none" />{{ product_color_grid }}{{ customify_text_widget }}
  37. <table width="100%" border="0" cellspacing="0" cellpadding="0" name="id" style="display:block;!important">
  38. <tbody>
  39. <tr class="{% cycle 'rx','ry' %}">{% for option in product.options %}
  40. <th>{{ option }}</th> {% endfor %}
  41. <th scope="col" class="center">Price</th>
  42. <th scope="col" style="width: 80px;" class="textright">Quantity</th>
  43. </tr> {% for variant in product.variants %} {% if variant.available %}
  44. <tr class="{% cycle 'xx','yy' %}" id="variant_tr-{{ variant.id }}"> {% for option in product.options %}
  45. <td class='text'>{{ variant.options[forloop.index0] }}</td> {% endfor %}
  46. <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>
  47. <td> {% if variant.available %}
  48. <input data-idx="{{ variant.id }}" class='qty_input' type="text" value="0" name="qty_{{variant.id}}" id="qty_{{ variant.id}}" /> {% else %} Sold {% endif %}</td>
  49. </tr> {% endif %} {% endfor %}</tbody>
  50. </table>
  51. <div class="msg-info" style="display: none; padding: 10px 0px;"></div>
  52. </div>
  53. <div class="customify-form-row">
  54. <button id="back-product" style="display: none; margin-right: 10px; " type="button" class="btn"> <span>&laquo; BACK</span> </button>
  55. <button type="submit" name="add" id="customify-addtocart" class="btn"> <span id="AddToCartText">ADD TO CART</span> </button>
  56. </div> {% endif %}</div>
  57. </div>
  58. {% if form_grid %}
  59. <br />
  60. <div class="customify-form-row"> {{ product.description }}</div>
  61. {% endif %}
  62.  
  63. {% unless form_method == 'grid' %}
  64. {{ "option_selection.js" | shopify_asset_url | script_tag }}
  65. {% endunless %}
  66.  
  67. <script type="text/javascript">
  68. var the_form = $("#customify-variant-table");
  69. success_div = the_form.find(".msg-info");
  70.  
  71. function add_to_cart_mass(t) {
  72. Shopify.queue = [];
  73. var i = 0;
  74. var data_form = JSON.stringify($("#customify_form").serializeArray());
  75. the_form.find('.qty_input').each(function() {
  76. idx = $(this).attr('data-idx');
  77. qty = $(this).val() * 1;
  78.  
  79. data_form.push({"variant_id": idx,"quantity": qty});
  80. data_form.properties.customify_id = t;
  81. if (qty > 0) {
  82. Shopify.queue.push({data_form});
  83. i++;
  84. }
  85. });
  86. if (i > 0) Shopify.moveAlong();
  87. }
  88. Shopify.moveAlong = function() {
  89. if (Shopify.queue.length) {
  90. $('#customify-addtocart').attr('disable', true).html("<span id='AddToCartText'>Processing..</span>");
  91. var request = Shopify.queue.shift();
  92. Shopify.addItem(request.variant_id, request.quantity, request.properties, Shopify.moveAlong);
  93. } else {
  94. showModal('<span>Item(s) Added to the Cart!</span> <a href="/cart">View cart</a>').fadeIn(300).delay(7000).fadeOut(300);
  95. $('#customify-addtocart').attr('disable', false).html("<span id='AddToCartText'>" + add_to_cart_text + "</span>");
  96. }
  97. };
  98. Shopify.addItem = function(id, qty, properties, callback) {
  99. var params = {
  100. quantity: qty,
  101. id: id
  102. };
  103. if (properties != false) {
  104. params.properties = properties;
  105. }
  106. $.ajax({
  107. type: 'POST',
  108. url: '/cart/add.js',
  109. dataType: 'json',
  110. data: params,
  111. success: function() {
  112. if (typeof callback === 'function') {
  113. callback();
  114. }
  115. },
  116. error: function() {}
  117. });
  118. }
  119.  
  120.  
  121. $(document).ready(function() {
  122. function getUrlParams(e, n) {
  123. n || (n = window.location.href), e = e.replace(/[\[\]]/g, "\$&");
  124. var r = new RegExp("[?&]" + e + "(=([^&#]*)|&|#|$)"),
  125. a = r.exec(n);
  126. return a ? a[2] ? decodeURIComponent(a[2].replace(/\+/g, " ")) : "" : null
  127. }
  128. var variant_id = getUrlParams("variant");
  129. $("select[name='id']").val(variant_id);
  130. console.log("script proceed");
  131. var selectCallback2 = function(variant, selector) {
  132. $("#variant_price").html(Shopify.formatMoney(variant.price, "{{ shop.money_with_currency_format }}"));
  133. $("#compare_price").html(Shopify.formatMoney(variant.compare_at_price, "{{ shop.money_with_currency_format }}"));
  134. if (variant.inventory_management == "shopify" && variant.inventory_policy == "deny" && variant.old_inventory_quantity == 0) {
  135. $("#customify-addtocart").prop("disabled", true);
  136. $("#recreation-button").hide();
  137. $("#AddToCartText").text("SOLD OUT");
  138. } else {
  139. $("#recreation-button").show();
  140. $("#customify-addtocart").prop("disabled", false);
  141. $("#AddToCartText").text("ADD TO CART");
  142. }
  143. };
  144. jQuery(function($) {
  145. new Shopify.OptionSelectors("productSelect", {
  146. product: {{ product | json }},
  147. onVariantSelected: selectCallback2,
  148. enableHistoryState: true
  149. });
  150. {% if product.options.size == 1 and product.options.first != "Title" %}
  151. $(".selector-wrapper:eq(0)").prepend('<label for="productSelect-option-0">{{ product.options.first | escape }}</label>');
  152. {% endif %}
  153. {% if product.variants.size == 1 and product.variants.first.title contains "Default" %}
  154. $(".selector-wrapper").hide(); {% endif %}
  155. });
  156. });
  157.  
  158. function add_to_cart(t) {
  159. document.getElementById("customify_id").value = t;
  160. document.getElementById("customify_form").submit();
  161. }
  162. $(window).load(function() {
  163. $("#customify_form div").removeClass("selectreplace");
  164. });
  165. </script>
  166. <script type="text/javascript">
  167. $(document).ready(function() {
  168. if ($("#main-container").parents(".customify-back").length > 0) {
  169. $("#back-product").show().attr("onclick", "window.location='{{ product.url }}'");
  170. }
  171. });
  172.  
  173. function showModal(htmlMessage, fullscreen, type) {
  174.  
  175. type = type === undefined ? '' : type;
  176.  
  177. var $body = $('body').addClass('fpd-overflow-hidden'),
  178. fullscreenCSS = fullscreen ? 'fpd-fullscreen' : '';
  179. html = '<div class="fpd-modal-internal fpd-modal-overlay"><div class="fpd-modal-wrapper fpd-shadow-3"><div class="fpd-modal-close"><span class="fpd-icon-close"></span></div><div class="fpd-modal-content"></div></div></div>';
  180.  
  181. if($('.fpd-modal-internal').length === 0) {
  182.  
  183. $body.append(html)
  184. .children('.fpd-modal-internal:first').click(function(evt) {
  185.  
  186. $target = $(evt.target);
  187. if($target.hasClass('fpd-modal-overlay')) {
  188.  
  189. $target.find('.fpd-modal-close').click();
  190.  
  191. }
  192.  
  193. });
  194.  
  195. }
  196.  
  197. if(type === 'prompt') {
  198. htmlMessage = '<input placeholder="'+htmlMessage+'" /><span class="fpd-btn"></span>';
  199. }
  200.  
  201. $body.children('.fpd-modal-internal').attr('data-type', type).removeClass('fpd-fullscreen').addClass(fullscreenCSS)
  202. .fadeIn(300).find('.fpd-modal-content').html(htmlMessage);
  203.  
  204. return $body.children('.fpd-modal-internal');
  205.  
  206. }
  207. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement