I created a site using your Classifieds site as a starting point. One change I am trying to make is to allow an option for people buying an ad to name their price. To do this, I want to use the Woo Commerce Name Your Price Extension. I've already set up the product and it works itself but it doesn't seem to work using the [woocommerce_checkout] shortcode. Is there another shortcode to use so that the variables can be selected and passed along?
But the above post is from 2 years ago. I think this should be included in Toolset as others are asking for this as well.
I can provide you with a copy of the Woo Commerce Name Your Price Extension for testing purposes if neeeded, it is attached as a jpg, just rename to zip.
We are mainly focused on supporting the Woocommerce core at the moment but you will need to open a feature request ticket in order for this to be added.
The plugin you suggests allows the user to suggest the price of the product they want to purchase correct? So you essentially want them to be able to name the price of the ad they are creating with Toolset Forms.
Have you tried this hook here ?
function es_donation_amount($post_id, $form_data) {
// if a specific form
if ($form_data['id']==FORM_ID) {
$new_price = get_post_meta($post_id, 'CUSTOM_FIELD', true);
$old_price = get_post_meta(PRODUCT_ID, '_regular_price', true);
update_post_meta(PRODUCT_ID, '_price', $new_price, $old_price);
update_post_meta(PRODUCT_ID '_regular_price', $new_price, $old_price);
}
}
add_action('cred_before_save_data', 'es_donation_amount', 10, 2);
No I have not tried the hook you suggest. Can you give me a little more advice on how to implement it? I'm using the Snappy Snippets Plugin to implement any php changes but any instructions on exactly what else I'd need to do would be helpful.
Based on this code all that is to change the values.
function es_donation_amount($post_id, $form_data) {
// if a specific form
if ($form_data['id']==FORM_ID) {
$new_price = get_post_meta($post_id, 'CUSTOM_FIELD', true);
$old_price = get_post_meta(PRODUCT_ID, '_regular_price', true);
update_post_meta(PRODUCT_ID, '_price', $new_price, $old_price);
update_post_meta(PRODUCT_ID '_regular_price', $new_price, $old_price);
}
}
add_action('cred_before_save_data', 'es_donation_amount', 10, 2);
So where you see PRODUCT_ID you need to set it to the ID of the product that you are using. Secondly CUSTOM_FIELD needs to be the slug of the custom field that you will be using for the users to enter the price the of the item.