Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Add new check condition for custom price field
- This topic has 6 replies, 2 voices, and was last updated 5 years, 9 months ago by WCFM Forum.
- AuthorPosts
- February 12, 2019 at 7:02 am #47828MOHOParticipant
“_wc_cost_price” this is my custom price field in single product
I need custom check condition
1. if “_wc_cost_price” < 0
show “出貨成本價要大於零!”2. if “price” < “_wc_cost_price”
show “售價要大於出貨成本價!”When vendor user submit show red error message like your other
Attachments:
You must be logged in to view attached files. - February 12, 2019 at 7:07 am #47833MOHOParticipant
“mrp_cost_price” this is my custom price field in variable product
I need custom check condition for each variable option
1. if “mrp_cost_price” <= 0
show “出貨成本價要大於零!”2. if “price” < “mrp_cost_price”
show “售價要大於出貨成本價!”When vendor user submit show red error message like your other red error message
Attachments:
You must be logged in to view attached files. - February 12, 2019 at 7:20 am #47836MOHOParticipant
sorry
“_wc_cost_price” <= 0
“mrp_cost_price” <= 0all change to “<= 0” condition
- February 14, 2019 at 10:34 am #48152WCFM ForumMember
HI,
Is there any condition check right now?
Thank You
- February 14, 2019 at 10:35 am #48153WCFM ForumMember
If so, then please give me those codes.
- February 14, 2019 at 12:49 pm #48192MOHOParticipant
“Is there any condition check right now?”
I list in the top, so i must give you the clearly check condition logic in doc???
- February 16, 2019 at 5:21 pm #48541WCFM ForumMember
Hi,
Here is your code for the purpose –
add_filter( 'wcfm_form_custom_validation', function( $wcfm_products_manage_form_data, $form_manager ) { if( $form_manager == 'product_manage' ) { if( $wcfm_products_manage_form_data['product_type'] == 'simple' ) { $regular_price = isset( $wcfm_products_manage_form_data['regular_price'] ) ? wc_clean( $wcfm_products_manage_form_data['regular_price'] ) : ''; $_wc_cost_price = isset( $wcfm_products_manage_form_data['_wc_cost_price'] ) ? wc_clean( $wcfm_products_manage_form_data['_wc_cost_price'] ) : ''; if( !$_wc_cost_price || ( $_wc_cost_price < 0 ) ) { $custom_validation_results['has_error'] = true; $custom_validation_results['message'] = '出貨成本價要大於零!'; return $custom_validation_results; } if( $regular_price && ( $regular_price < $_wc_cost_price ) ) { $custom_validation_results['has_error'] = true; $custom_validation_results['message'] = '售價要大於出貨成本價!'; return $custom_validation_results; } } elseif( $wcfm_products_manage_form_data['product_type'] == 'variable' ) { if(isset($wcfm_products_manage_form_data['variations']) && !empty($wcfm_products_manage_form_data['variations'])) { foreach($wcfm_products_manage_form_data['variations'] as $variations) { $regular_price = isset( $variations['regular_price'] ) ? wc_clean( $variations['regular_price'] ) : ''; $mrp_cost_price = isset( $variations['mrp_cost_price'] ) ? wc_clean( $variations['mrp_cost_price'] ) : ''; if( !$mrp_cost_price || ( $mrp_cost_price < 0 ) ) { $custom_validation_results['has_error'] = true; $custom_validation_results['message'] = '出貨成本價要大於零!'; return $custom_validation_results; } if( $regular_price && ( $regular_price < $mrp_cost_price ) ) { $custom_validation_results['has_error'] = true; $custom_validation_results['message'] = '售價要大於出貨成本價!'; return $custom_validation_results; } } } } } return $wcfm_products_manage_form_data; }, 50 , 2 );
Thank You
- AuthorPosts
- The topic ‘Add new check condition for custom price field’ is closed to new replies.