Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Subscriptions As a Variation Setup

sparkweb Aug 12th, 2011 134 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1.         //CUSTOM SUBSCRIPTION CODE HERE
  2.         echo '<input type="hidden" name="x:sub_frequency" id="frequency_field_' . $product['id'] . '" value="" />';
  3.         echo '<input type="hidden" name="x:sub_frequency1" id="frequency_holder1_' . $product['id'] . '" value="sub_frequency' . foxyshop_get_verification("sub_frequency", "1w") . '" />';
  4.         echo '<input type="hidden" name="x:sub_frequency2" id="frequency_holder2_' . $product['id'] . '" value="sub_frequency' . foxyshop_get_verification("sub_frequency", "2w") . '" />';
  5.  
  6.         //Writes Javascript
  7.         ?>
  8.         <script type="text/javascript">
  9.         jQuery(document).ready(function($) {
  10.                
  11.                 $("select.variation-delivery-frequency").bind("change ready", function() {
  12.                         var currentval = $(this).val();
  13.                         var product_id = $(this).parents("form").attr("id");
  14.                         product_id = product_id.replace("foxyshop_product_form_","");
  15.                         checkField(currentval, product_id);
  16.                 });
  17.                
  18.                 function checkField(currentval, product_id) {
  19.                         if (currentval.indexOf('Weekly') >= 0) {
  20.                                 setFrequency(1, product_id);
  21.                         } else if (currentval.indexOf('Every Two Weeks') >= 0) {
  22.                                 setFrequency(2, product_id);
  23.                         } else {
  24.                                 setFrequency(0, product_id);
  25.                         }
  26.                 }
  27.                
  28.                 function setFrequency(fr, product_id) {
  29.                         if (fr == 0) {
  30.                                 $("#frequency_field_"+product_id).val("").attr("name","x:sub_frequency");
  31.                         } else if (fr == 1) {
  32.                                 $("#frequency_field_"+product_id).val("1w").attr("name",$("#frequency_holder1_"+product_id).val());
  33.                         } else if (fr == 2) {
  34.                                 newval = $("#frequency_holder2_"+product_id).val();
  35.                                 $("#frequency_field_"+product_id).attr("value","2w").attr("name",$("#frequency_holder2_"+product_id).val());
  36.                         }
  37.                 }
  38.                
  39.                 //Run on Initialization
  40.                 $("select.variation-delivery-frequency").each(function() {
  41.                         var currentval = $(this).val();
  42.                         var product_id = $(this).parents("form").attr("id");
  43.                         product_id = product_id.replace("foxyshop_product_form_","");
  44.                         checkField(currentval, product_id);
  45.                 });
  46.                
  47.         });
  48.         </script>
  49.         <?php
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top