Skip to content

Instantly share code, notes, and snippets.

@fervous
Forked from digitalchild/functions.php
Created January 3, 2017 17:47
Show Gist options
  • Save fervous/122a54a12bc284f76a539df7882ae9fe to your computer and use it in GitHub Desktop.
Save fervous/122a54a12bc284f76a539df7882ae9fe 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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment