Last active
June 21, 2018 15:58
-
-
Save pablo-sg-pacheco/a592f3a7362a630735ca0a7571e28fb4 to your computer and use it in GitHub Desktop.
Replace input field by dropdown using the Product Open Pricing plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Remove default input | |
add_filter( 'option_' . 'alg_wc_product_open_pricing_frontend_template', 'popwc_remove_default_input' , 10, 2 ); | |
function popwc_remove_default_input($value){ | |
if(!is_admin()){ | |
$value=''; | |
} | |
return $value; | |
} | |
// Add custom input | |
add_action( 'woocommerce_before_add_to_cart_button', 'popwc_add_input_field_to_frontend' , PHP_INT_MAX ); | |
function popwc_add_input_field_to_frontend(){ | |
global $product; | |
$product_id = $product->get_id(); | |
$post_meta = get_post_meta($product_id,'custom_field'); | |
?> | |
<select id="alg_open_price" name="alg_open_price"> | |
<option>4</option> | |
<option>6</option> | |
</select> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Product Open Pricing plugin