Advertisement
sparkweb

FoxyShop Donation Code

Sep 14th, 2011
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. <?php
  2. global $foxyshop_settings;
  3. $product = array("code" => "donation");
  4. ?>
  5.  
  6. <form action="https://<?php echo esc_attr($foxyshop_settings['domain']); ?>/cart" method="post" accept-charset="utf-8">
  7.     <input type="hidden" name="name<?php echo foxyshop_get_verification('name', 'Donation'); ?>" value="Donation" />
  8.     <input type="hidden" name="code<?php echo foxyshop_get_verification('code', 'donation'); ?>" value="donation" />
  9.     <label for="donate_500"><input type="radio" name="__donation" id="donate_500" value="500" />$500</label>
  10.     <label for="donate_250"><input type="radio" name="__donation" id="donate_250" value="250" />$250</label>
  11.     <label for="donate_100"><input type="radio" name="__donation" id="donate_100" value="100" />$100</label>
  12.     <label for="donate_50"><input type="radio" name="__donation" id="donate_50" value="50" />$50</label>
  13.     <label for="donate_0"><input type="radio" name="__donation" id="donate_0" value="0" />Other</label>
  14.     <label class="donate_other" for="price">Please specify</label>
  15.     <input type="text" name="price<?php echo foxyshop_get_verification('price', '--OPEN--'); ?>" id="price" class="donate_other" value="0" />
  16.  
  17.     <input type="submit" value="Add To Cart">
  18. </form>
  19.  
  20. <script type="text/javascript" charset="utf-8">
  21. jQuery(function($) {
  22.     $(".donate_other").hide();
  23.     $("input[name='__donation']").change(function() {
  24.         toggle_donation();
  25.     });
  26.  
  27.     // Update the price based on preselected donation value if there is one
  28.     if ($("input[name='__donation']:checked").length > 0) {
  29.         toggle_donation();
  30.     }
  31. });
  32.  
  33. function toggle_donation() {
  34.     var cur_donation = jQuery("input[name='__donation']:checked").val();
  35.     if (cur_donation > 0) {
  36.         jQuery("#price").val(cur_donation);
  37.         jQuery(".donate_other").hide();
  38.     } else {
  39.         jQuery("#price").val("");
  40.         jQuery(".donate_other").show();
  41.     }
  42. }
  43. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement