Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This is a way to allow your customers to select their subscription frequency
- //Create a dropdown variation called "Delivery Frequency" and then create a hidden input as seen below for each of the entries
- //This code goes in foxyshop-single-product.php before the end of the form
- //CUSTOM SUBSCRIPTION CODE HERE
- echo '<input type="hidden" name="x:sub_frequency1" id="frequency_holder1_' . $product['id'] . '" value="sub_frequency' . foxyshop_get_verification("sub_frequency", "1m") . '" />'."\n";
- echo '<input type="hidden" name="x:sub_frequency2" id="frequency_holder2_' . $product['id'] . '" value="sub_frequency' . foxyshop_get_verification("sub_frequency", "2m") . '" />'."\n";
- echo '<input type="hidden" name="x:sub_frequency3" id="frequency_holder3_' . $product['id'] . '" value="sub_frequency' . foxyshop_get_verification("sub_frequency", "3m") . '" />'."\n";
- //Writes Javascript
- ?>
- <script type="text/javascript">
- jQuery(document).ready(function($) {
- $("select.variation-delivery-frequency").bind("change ready", function() {
- var currentval = $(this).prop("selectedIndex");
- var product_id = $(this).parents("form").attr("id");
- product_id = product_id.replace("foxyshop_product_form_","");
- setFrequency(currentval, product_id);
- });
- function setFrequency(fr, product_id) {
- fr++;
- $("#fs_sub_frequency_" + product_id).val(fr+"m").attr("name",$("#frequency_holder" + fr + "_" + product_id).val());
- }
- //Run on Initialization
- $("select.variation-delivery-frequency").each(function() {
- var currentval = $(this).prop("selectedIndex");
- var product_id = $(this).parents("form").attr("id");
- product_id = product_id.replace("foxyshop_product_form_","");
- setFrequency(currentval, product_id);
- });
- });
- </script>
- <?php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement