Advertisement
sparkweb

FoxyShop Donation Code (Single Field)

Sep 15th, 2011
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript" charset="utf-8">
  2. jQuery(function($) {
  3.    
  4.     var open_price_field_class = "variation-enter-your-price"; //If you change your field name, put the new class here
  5.     var product_id = <?php echo $product['id']; ?>;
  6.     var default_price = $("#fs_price_" + product_id).val(); // set to nothing if you don't want default price
  7.    
  8.     //Add a x: to the front of the open price field so it doesn't show up in cart as a product attribute
  9.     $("#foxyshop_product_form_" + product_id + " input." + open_price_field_class)
  10.         .attr("name", "x:" + $("#foxyshop_product_form_" + product_id + " input." + open_price_field_class)
  11.         .attr("name")).val(default_price);
  12.    
  13.     //Hide Display Price
  14.     if ($("#foxyshop_product_form_" + product_id + " input." + open_price_field_class).length > 0) {
  15.         $("#foxyshop_product_form_" + product_id + " .foxyshop_price").hide();
  16.         $("#fs_price_" + product_id + "").attr("name", "price<?php echo foxyshop_get_verification('price', '--OPEN--'); ?>");
  17.         //$("#fs_price_" + product_id).val(""); //Uncomment line if you want to set default price to nothing
  18.     }
  19.  
  20.     //Runs every time a key is pressed in the open price field
  21.     $("#foxyshop_product_form_" + product_id + " input." + open_price_field_class).keyup(function() {
  22.        
  23.         //Set the new price in the hidden form field
  24.         $("#fs_price_" + product_id + "").val($(this).val());
  25.     });
  26.  
  27. });
  28. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement