Skip to content

Instantly share code, notes, and snippets.

@VizualAbstract
Last active June 2, 2017 19:11
Show Gist options
  • Select an option

  • Save VizualAbstract/3477d17c48982927cbc004234f5e3448 to your computer and use it in GitHub Desktop.

Select an option

Save VizualAbstract/3477d17c48982927cbc004234f5e3448 to your computer and use it in GitHub Desktop.
<script>
(function() {
var ReCharge = {}
ReCharge.delay = 1;
ReCharge.listener_delay = 1;
ReCharge.product_id = {{ product.id }};
ReCharge.subscription_id = {{ subscription_id }};
ReCharge.subscription_only = {{ subscription_only }};
ReCharge.subscription_first = {{ select_subscription_first }};
ReCharge.default_purchase_type = '{{ default_purchase_type }}';
ReCharge.discount = {{ discount_percentage }};
ReCharge.currency_prefix = '{{ currency_prefix }}';
ReCharge.currency_suffix = '{{ currency_suffix }}';
ReCharge.maps = {
original_id_to_duplicate_id: {
{% for variant in product.variants %}
{{ variant.id }}: '{{ variant.metafields.subscriptions.discount_variant_id }}',
{% endfor %}
},
original_id_to_price: {
{% for variant in product.variants %}
{{ variant.id }}: '{{ variant.price | money_without_currency }}',
{% endfor %}
},
duplicate_id_to_price: {
{% for variant in product.variants %}
{{ variant.metafields.subscriptions.discount_variant_id }}: '{{ variant.metafields.subscriptions.discount_variant_price }}',
{% endfor %}
}
}
ReCharge.product_form = getProductForm(ReCharge.product_id);
ReCharge.elements = {
shipping_frequency_options: ReCharge.product_form.querySelectorAll('#rc_autodeliver_options')[0],
shipping_interval_type: ReCharge.product_form.querySelectorAll('#rc_shipping_interval_unit_type')[0],
shipping_interval_frequency: ReCharge.product_form.querySelectorAll('#rc_shipping_interval_frequency')[0],
purchase_types: ReCharge.product_form.querySelectorAll('[name="purchase_type"]'),
selected_purchase_type: ReCharge.product_form.querySelectorAll('#rc_purchase_type_' + ReCharge.default_purchase_type)[0],
type_onetime: ReCharge.product_form.querySelectorAll('#rc_purchase_type_onetime')[0],
type_autodeliver: ReCharge.product_form.querySelectorAll('#rc_purchase_type_autodeliver')[0],
product_variant_selector: ReCharge.product_form.querySelectorAll('[name="id"]')[0],
duplicate_variant_selector: ReCharge.product_form.querySelectorAll('#rc_duplicate_selector')[0],
price_product: getProductPrice(),
price_onetime: ReCharge.product_form.querySelectorAll('#rc_price_onetime')[0],
price_autodeliver: ReCharge.product_form.querySelectorAll('#rc_price_autodeliver')[0],
quantity: ReCharge.product_form.querySelectorAll('[name="quantity"]')[0],
}
}())
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment