Advertisement
sparkweb

FoxyShop: Dropdown for adding a subscription

Oct 10th, 2014
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.37 KB | None | 0 0
  1. //This code goes in foxyshop-single-product.php in the custom code section
  2. ?>
  3. <script type="text/javascript">
  4. jQuery(document).ready(function($){
  5.     $(".variation-payment-type").change(function() {
  6.         update_payment_options();
  7.     });
  8.  
  9.     //Set Defaults
  10.     $("#fs_sub_frequency_<?php echo $product['id']; ?>").attr("name", "sub_frequency<?php echo foxyshop_get_verification("sub_frequency", "--OPEN--"); ?>");
  11.     $("#fs_sub_enddate_<?php echo $product['id']; ?>").attr("name", "sub_enddate<?php echo foxyshop_get_verification("sub_enddate", "--OPEN--"); ?>");
  12.     update_payment_options();
  13. });
  14. function update_payment_options() {
  15.     var current_payment_option = $("select.variation-payment-type").val();
  16.     if (current_payment_option.match(/Buy Now/gi)) {
  17.         $("#fs_sub_frequency_<?php echo $product['id']; ?>").val("");
  18.         $("#fs_sub_enddate_<?php echo $product['id']; ?>").val("");
  19.     }
  20.     if (current_payment_option.match(/3 Month/gi)) {
  21.         $("#fs_sub_frequency_<?php echo $product['id']; ?>").val("3m");
  22.         $("#fs_sub_enddate_<?php echo $product['id']; ?>").val("<?php echo date('Y-m-d', strtotime('+2 months +25 days')); ?>");
  23.     }
  24.     if (current_payment_option.match(/6 Month/gi)) {
  25.         $("#fs_sub_frequency_<?php echo $product['id']; ?>").val("6m");
  26.         $("#fs_sub_enddate_<?php echo $product['id']; ?>").val("<?php echo date('Y-m-d', strtotime('+5 months +25 days')); ?>");
  27.     }
  28. }
  29.  
  30. </script>
  31. <?php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement