Skip to content

Instantly share code, notes, and snippets.

@digitalchild
Created April 16, 2016 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save digitalchild/97a0daf2757ffe3d9f3c6ab1c3dc0c1b to your computer and use it in GitHub Desktop.
Save digitalchild/97a0daf2757ffe3d9f3c6ab1c3dc0c1b to your computer and use it in GitHub Desktop.
Make fields required
<?php
// You will also have to modify the store-settings.php template in templates/dashboard/store-settings.php
// Line 20 replace the form start with this
// <form method="post" action="" class="wcv-form wcv-formvalidator">
//do this in the core file not an override as this was missed and I've added it to core and will be upgrade safe next time
// Paypal required
function wcv_paypal_required( $args ){
$custom_attributes = array(
'data-rules' => 'required',
'data-error' => __( 'Paypal address is required', 'wcvendors-pro' ),
);
$args['label'] = 'Something Else';
$args['custom_attributes'] = $custom_attributes;
error_log( print_r( $args, true ) );
return $args;
} // wcv_paypal_required()
add_filter( 'wcv_vendor_paypal_address', 'wcv_paypal_required' );
// Price required
function wcv_price_required( $args ){
$args['custom_attributes']['data-rules'] = 'required|decimal';
$args['custom_attributes']['data-error'] =__( 'Price is required and should be a number.', 'wcvendors-pro' );
return $args;
} // wcv_price_required()
add_filter( 'wcv_product_price', 'wcv_price_required' );
// National Shipping required
function wcv_national_shipping_required( $args ){
$custom_attributes = array(
'data-rules' => 'required|decimal',
'data-error' => __( 'National shipping is required.', 'wcvendors-pro' ),
);
$args['custom_attributes'] = $custom_attributes;
return $args;
} // wcv_national_shipping_required()
add_filter( 'wcv_product_shipping_fee_national', 'wcv_national_shipping_required' );
@al3xstanhope
Copy link

Awesome! Just what I was looking for! Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment