Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript" charset="utf-8">
- jQuery(function($) {
- var product_id = <?php echo $product['id']; ?>; //Stores the product ID
- var open_price_field_name = "Donation_Amount"; //This is the name of your open price field
- var radio_button_selectors_class = "variation-donation"; //This is the class assigned to your radio buttons
- var custom_selector_dkey = "custom-price"; //This is the dkey that will make your custom price field show up
- //Add a x: to the front of the open price field so it doesn't show up in cart as a product attribute
- $("#foxyshop_product_form_" + product_id + " input[name^='" + open_price_field_name + "']").attr("name", "x:" + $("#foxyshop_product_form_" + product_id + " input[name^='" + open_price_field_name + "']").attr("name"))
- //Runs every time the radio buttons are changed
- $("." + radio_button_selectors_class).click(function() {
- //If the "other" selection is made
- if ($("." + radio_button_selectors_class + ":checked").attr("displaykey") == custom_selector_dkey) {
- //Hide the display price
- $("#foxyshop_product_form_" + product_id + " .foxyshop_price").hide();
- //Get the new price from the Price Entry Field
- new_price = $("#foxyshop_product_form_" + product_id + " input[name^='x:" + open_price_field_name + "']").val();
- //Set the #price field name to then --OPEN-- hash to allow an open entry and stick in the contents of the new price
- $("#fs_price_" + product_id + "").attr("name", "price<?php echo foxyshop_get_verification('price', '--OPEN--'); ?>").val(new_price);
- //If a preset price is selected
- } else {
- //Set the #price field name to the default price and the value to the x:original price value
- $("#fs_price_" + product_id + "").attr("name", $("#fs_price_" + product_id).attr("name")).val($("#originalprice_" + product_id + "").val());
- //Show the Price
- $("#foxyshop_product_form_" + product_id + " .foxyshop_price").show();
- }
- });
- //Runs every time a key is pressed in the open price field
- $("#foxyshop_product_form_" + product_id + " input[name^='x:" + open_price_field_name + "']").keyup(function() {
- //Set the new price in the hidden form field
- $("#fs_price_" + product_id + "").attr("name", "price<?php echo foxyshop_get_verification('price', '--OPEN--'); ?>").val($(this).val());
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement