Advertisement
wclovers

Untitled

Sep 27th, 2023
937
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. add_filter( 'wcfm_form_custom_validation', function($form_data, $wcfm_screen) {
  2.     $error = [];
  3.     if ('product_manage' == $wcfm_screen) {
  4.         $minimum_price = 1;
  5.  
  6.         if ( isset($form_data['regular_price']) && isset($form_data['sale_price']) ) {
  7.             $regular_price = $form_data['regular_price'] ? $form_data['regular_price'] : 0;
  8.             $sale_price = $form_data['sale_price'] ? $form_data['sale_price'] : 0;
  9.  
  10.             if (min($regular_price,$sale_price) < $minimum_price) {
  11.                 $error['has_error'] = true;
  12.                 $error['message'] = sprintf(__('Price can not be less than %1$s%2$s', 'wc-frontend-manager'), get_woocommerce_currency_symbol(), $minimum_price);
  13.             }
  14.         }
  15.     }
  16.     return !empty($error) ? $error : $form_data;
  17. }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement