Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Replace input field by dropdown using the Product Open Pricing plugin
<?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
}
@pablo-sg-pacheco

This comment has been minimized.

Copy link
Owner Author

pablo-sg-pacheco commented Jun 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.