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

FoxyShop: Subscription as a Variation Setup

sparkweb Jan 17th, 2012 304 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. //This is a way to allow your customers to select their subscription frequency
  2. //Create a dropdown variation called "Delivery Frequency" and then create a hidden input as seen below for each of the entries
  3. //This code goes in foxyshop-single-product.php before the end of the form
  4.  
  5. //CUSTOM SUBSCRIPTION CODE HERE
  6. echo '<input type="hidden" name="x:sub_frequency1" id="frequency_holder1_' . $product['id'] . '" value="sub_frequency' . foxyshop_get_verification("sub_frequency", "1m") . '" />'."\n";
  7. echo '<input type="hidden" name="x:sub_frequency2" id="frequency_holder2_' . $product['id'] . '" value="sub_frequency' . foxyshop_get_verification("sub_frequency", "2m") . '" />'."\n";
  8. echo '<input type="hidden" name="x:sub_frequency3" id="frequency_holder3_' . $product['id'] . '" value="sub_frequency' . foxyshop_get_verification("sub_frequency", "3m") . '" />'."\n";
  9.  
  10. //Writes Javascript
  11. ?>
  12. <script type="text/javascript">
  13. jQuery(document).ready(function($) {
  14.         $("select.variation-delivery-frequency").bind("change ready", function() {
  15.                 var currentval = $(this).prop("selectedIndex");
  16.                 var product_id = $(this).parents("form").attr("id");
  17.                 product_id = product_id.replace("foxyshop_product_form_","");
  18.                 setFrequency(currentval, product_id);
  19.         });
  20.         function setFrequency(fr, product_id) {
  21.                 fr++;
  22.                 $("#fs_sub_frequency_" + product_id).val(fr+"m").attr("name",$("#frequency_holder" + fr + "_" + product_id).val());
  23.         }
  24.         //Run on Initialization
  25.         $("select.variation-delivery-frequency").each(function() {
  26.                 var currentval = $(this).prop("selectedIndex");
  27.                 var product_id = $(this).parents("form").attr("id");
  28.                 product_id = product_id.replace("foxyshop_product_form_","");
  29.                 setFrequency(currentval, product_id);
  30.         });
  31. });
  32. </script>
  33. <?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