boldsupport of Recurring Orders
4/6/2017 - 1:14 AM

Subscription Buy Button theme install files x2 Shopify page templates These two files are required to be installed on the theme, in additio

Subscription Buy Button theme install files x2 Shopify page templates

These two files are required to be installed on the theme, in addition to creating two associated pages before the Buy Button creation tool would work.

{% layout none %}
{
{% assign count = 0 %}
{% for product in collections.all-products.products %}
{% for variant in product.variants %}
{% if variant.metafields.bold_rp.rp_group_id %}
{% assign has_subscriptions = true %}
{% else %}
{% assign has_subscriptions = false %}
{% endif %}
{% endfor %}
{% if has_subscriptions %}{% unless count == 0 %},{% endunless %}{% assign count = count | plus: 1 %}
"{{ product.id }}": {
"title":"{{ product.title }}",
"featured_image":"https://{{ product.images.first.src | img_url: '128x128', crop: 'center' | remove_first: "//" }}",
"money_format":"{{ shop.money_format }}",
"variants":
{
{% for variant in product.variants %}
{% if variant.metafields.bold_rp.rp_group_id %}
"{{ variant.id }}": {
"title":"{% if variant.title == 'Default Title' %}Default Variant{% else %}{{ variant.title }}{% endif %}",
"group_id":"{{ variant.metafields.bold_rp.rp_group_id }}",
"price":"{{ variant.price }}"
}{% unless forloop.rindex == 1 %},{% endunless %}
{% endif %}
{% endfor %}
}
}
{% endif %}
{% endfor %}
}
{% layout none %}
<html>
  <head>
    <script
           src="https://code.jquery.com/jquery-3.1.1.slim.min.js"
           integrity="sha256-/SIrNqv8h6QGKDuNoLGA4iret+kyesCkHGzVUUV0shc="
           crossorigin="anonymous"></script>
  </head>
  <body>
    {% assign split_domain = shop.permanent_domain | split: '.' %}
    {% assign short_domain = split_domain[0] %}
    <form name="ignore_me">
      <input type="hidden" id="page_is_dirty" name="page_is_dirty" value="0" />
    </form>
    <script>
      var dirty_bit = document.getElementById('page_is_dirty');
      if (dirty_bit.value == '1') window.history.go(-1);
      function mark_page_dirty() {
          dirty_bit.value = '1';
      }
      mark_page_dirty();
    </script>
    <form id="subscribe-form" enctype="multipart/form-data" method="POST" action="https://recurringcheckout.com/s/{{ short_domain }}/checkout/recurring_product?shop_url={{ shop.permanent_domain }}" novalidate>
     
      <input type="hidden" class="variant_id" name="id" />
      <input type="hidden" class="is_recurring" name="recurring_radio_btn" value="1" />
      <input type="hidden" class="frequency_num" name="properties[frequency_num]" />
      <input type="hidden" class="frequency_type" name="properties[frequency_type]" />
      <input type="hidden" class="total_recurrences" name="properties[total_recurrences]" />
      <input type="hidden" class="prepaid_length_id" name="bold_ro_prepaid_duration" />
      <input type="hidden" class="frequency_num" name="frequency_num" />
      <input type="hidden" class="frequency_type" name="frequency_type" />
      <input type="hidden" class="total_recurrences" name="total_recurrences" />
      <input type="hidden" class="prepaid_length_id" name="prepaid_length_id" />
      <input type="hidden" class="is_prepaid" name="is_prepaid" />
      <input type="hidden" class="csrf_bold_token" name="csrf_bold_token" value="ae13d67bde0cfb4df78a5a0fab2a11a0" />
      <input type="hidden" class="quantity" name="quantities[]" value="1" />
      <input type="hidden" class="product_id" name="product_id[]" />
      <input type="hidden" class="variant_id" name="variant_id[]" />
      <input type="hidden" class="group_id" name="group_id" />
      <input type="hidden" class="note" name="note" />
      <input type="hidden" class="frequency_type_text" name="properties[frequency_type_text]" />
      <input type="hidden" class="group_id" name="properties[group_id]" />
      <input type="hidden" class="discounted_price" name="properties[discounted_price]" />
      <input type="hidden" class="_ro_discount_percentage" name="properties[_ro_discount_percentage]" />
      <input type="hidden" class="_ro_unformatted_price" name="properties[_ro_unformatted_price]" />
      <input name="shopify_customer_id" type="hidden" value="{{ customer.id }}" >
      <input name="email" type="hidden" value="{{ customer.email }}" >
      <input name="address1" type="hidden" value="{{ customer.default_address.address1 }}" >
      <input name="address2" type="hidden" value="{{ customer.default_address.address2 }}" >
      <input name="city" type="hidden" value="{{ customer.default_address.city }}" >
      <input name="company" type="hidden" value="{{ customer.default_address.company }}" >
      <input name="country" type="hidden" value="{{ customer.default_address.country }}" >
      <input name="first_name" type="hidden" value="{{ customer.default_address.first_name }}" >
      <input name="last_name" type="hidden" value="{{ customer.default_address.last_name }}" >
      <input name="phone" type="hidden" value="{{ customer.default_address.phone }}" >
      <input name="province" type="hidden" value="{{ customer.default_address.province }}" >
      <input name="zip" type="hidden" value="{{ customer.default_address.zip }}" >
     
    </form>
   
    <script>
 
      var QS = function () {
        var query_string = {};
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
         var pair = vars[i].split("=");
         if (typeof query_string[pair[0]] === "undefined") {
           query_string[pair[0]] = decodeURIComponent(pair[1]);
         } else if (typeof query_string[pair[0]] === "string") {
           var arr = [ query_string[pair[0]],decodeURIComponent(pair[1]) ];
           query_string[pair[0]] = arr;
         } else {
           query_string[pair[0]].push(decodeURIComponent(pair[1]));
         }
       }
       return query_string;
     }();
 
     jQuery(document).ready(function(){
       
       var freq_lang = [];
       freq_lang[1] = "Day(s)";
       freq_lang[2] = "Week(s)";
       freq_lang[3] = "Month(s)";
       freq_lang[5] = "Year(s)";
       
       if(typeof QS.g !== 'undefined' 
       && typeof QS.p !== 'undefined' 
       && typeof QS.v !== 'undefined' 
       && typeof QS.fn !== 'undefined' 
       && typeof QS.ft !== 'undefined'){
       
         $('.group_id').val(QS.g);
         $('.product_id').val(QS.p);
         $('.variant_id').val(QS.v);
         $('.frequency_type').val(QS.ft);
         $('.frequency_num').val(QS.fn);
         $('.frequency_type_text').val(freq_lang[QS.ft]);
         
         $('.total_recurrences').val(typeof QS.tr !== 'undefined'?QS.tr:$('.total_recurrences').val());
         $('.prepaid_length_id').val(typeof QS.pli !== 'undefined'?QS.pli:$('.prepaid_length_id').val());
         $('.is_prepaid').val(typeof QS.ip !== 'undefined'?QS.ip:$('.is_prepaid').val());
         $('.csrf_bold_token').val(typeof QS.csrf !== 'undefined'?QS.csrf:$('.csrf_bold_token').val());
         $('.quantity').val(typeof QS.q !== 'undefined'?QS.q:$('.quantity').val());
         $('.note').val(typeof QS.n !== 'undefined'?QS.n:$('.note').val());
         $('.discounted_price').val(typeof QS.dp !== 'undefined'?QS.dp:$('.discounted_price').val());
         $('._ro_discount_percentage').val(typeof QS.rdp !== 'undefined'?QS.rdp:$('._ro_discount_percentage'));
         $('._ro_unformatted_price').val(typeof QS.rup !== 'undefined'?QS.rup:$('._ro_unformatted_price').val());
         
         if(QS.tr && !QS.ip){
           $('.is_prepaid, .prepaid_length_id').remove();
         }
         else if(!QS.tr && !QS.ip){
           $('.is_prepaid, .prepaid_length_id, .total_recurrences').remove();
         }
         
       }
       else{
         
         console.log('missing parameters');
         
       }
 
       $('#subscribe-form').submit();
 
     });
 
   </script>
   
  </body>
</html>

#Subscription Buy Button theme install files ####x2 Shopify page templates

These two files are required to be installed on the theme, in addition to creating two associated pages before the Buy Button creation tool would work.