Advertisement
customfiy

customify new widget custom

Jan 21st, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.30 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. {% 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. <label for="Quantity" class="cst_qty_label">Quantity</label>
  18. <input type="number" id="Quantity" name="quantity" value="1" min="1" class="quantity-selector">
  19. </div>
  20. <div class="customify-form-row">
  21. <label id="note-label" for="note" class="cst_note_label" >Note</label>
  22. <textarea id="note" name="properties[customify_note]"></textarea>
  23. </div>
  24. <div class="customify-form-row">
  25. <button id="back-product" style="display: none; margin-right: 10px; " type="button" class="btn"> <span>&laquo; BACK</span> </button>
  26. <button type="submit" name="add" id="customify-addtocart" class="btn"> <span id="AddToCartText">ADD TO CART</span> </button>
  27. </div>
  28. </form>
  29. <div class="customify-form-row"> {{ product.description }}</div> {% else %} {% assign form_grid = true %}
  30. <div id="customify-variant-table">
  31. <input type="file" id="customify-upload" style="display: none" />{{ product_color_grid }}{{ customify_text_widget }}
  32. <table width="100%" border="0" cellspacing="0" cellpadding="0" name="id" style="display:block;!important">
  33. <tbody>
  34. <tr class="{% cycle 'rx','ry' %}">{% for option in product.options %}
  35. <th>{{ option }}</th> {% endfor %}
  36. <th scope="col" class="center cst_price_label">Price</th>
  37. <th scope="col" style="width: 80px;" class="cst_qty_label textright">Quantity</th>
  38. </tr> {% for variant in product.variants %} {% if variant.available %}
  39. <tr class="{% cycle 'xx','yy' %}" id="variant_tr-{{ variant.id }}"> {% for option in product.options %}
  40. <td class='text'>{{ variant.options[forloop.index0] }}</td> {% endfor %}
  41. <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>
  42. <td> {% if variant.available %}
  43. <input data-idx="{{ variant.id }}" class='qty_input' type="text" value="0" name="qty_{{variant.id}}" id="qty_{{ variant.id}}" /> {% else %} Sold {% endif %}</td>
  44. </tr> {% endif %} {% endfor %}</tbody>
  45. </table>
  46. <div class="msg-info" style="display: none; padding: 10px 0px;"></div>
  47. </div>
  48. <div class="customify-form-row">
  49. <button id="back-product" style="display: none; margin-right: 10px; " type="button" class="btn"> <span>&laquo; BACK</span> </button>
  50. <button type="submit" name="add" id="customify-addtocart" class="btn"> <span id="AddToCartText">ADD TO CART</span> </button>
  51. </div> {% endif %}</div>
  52. </div>
  53. <br />
  54. <div class="customify-form-row"> {{ product.description }}</div>
  55. {% unless form_grid %}
  56. {{ "option_selection.js" | shopify_asset_url | script_tag }}
  57. <script type="text/javascript">
  58. $(document).ready(function() {
  59. function getUrlParams(e, n) {
  60. n || (n = window.location.href), e = e.replace(/[\[\]]/g, "\$&");
  61. var r = new RegExp("[?&]" + e + "(=([^&#]*)|&|#|$)"),
  62. a = r.exec(n);
  63. return a ? a[2] ? decodeURIComponent(a[2].replace(/\+/g, " ")) : "" : null
  64. }
  65. var variant_id = getUrlParams("variant");
  66. $("select[name='id']").val(variant_id);
  67. console.log("script proceed");
  68. var selectCallback2 = function(variant, selector) {
  69. $("#variant_price").html(Shopify.formatMoney(variant.price, "{{ shop.money_with_currency_format }}"));
  70. $("#compare_price").html(Shopify.formatMoney(variant.compare_at_price, "{{ shop.money_with_currency_format }}"));
  71. if (variant.inventory_management == "shopify" && variant.inventory_policy == "deny" && variant.old_inventory_quantity == 0) {
  72. $("#customify-addtocart").prop("disabled", true);
  73. $("#recreation-button").hide();
  74. $("#AddToCartText").text("SOLD OUT");
  75. } else {
  76. $("#recreation-button").show();
  77. $("#customify-addtocart").prop("disabled", false);
  78. }
  79. };
  80. jQuery(function($) {
  81. new Shopify.OptionSelectors("productSelect", {
  82. product: {{ product | json }},
  83. onVariantSelected: selectCallback2,
  84. enableHistoryState: true
  85. }); {{ %
  86. if product.options.size == 1 and product.options.first != "Title" %
  87. }}$(".selector-wrapper:eq(0)").prepend('<label for="productSelect-option-0">{{ product.options.first | escape }}</label>'); {{ % endif %
  88. }} {{ %
  89. if product.variants.size == 1 and product.variants.first.title contains "Default" %
  90. }}
  91. $(".selector-wrapper").show(); {{ % endif %
  92. }}
  93. });
  94. });
  95.  
  96. $(window).on("load", function() {
  97. $("#customify_form div").removeClass("selectreplace");
  98. });
  99. </script> {% endunless %}
  100. <script type="text/javascript">
  101. $(document).ready(function() {
  102. if ($("#main-container").parents(".customify-back").length > 0) {
  103. $("#back-product").show().attr("onclick", "window.location='{{ product.url }}'");
  104. }
  105. });
  106. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement