This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* WC Vendors Pro -- Require a minimum, and a maximum price for vendors when adding/editing a product */ | |
add_filter( 'wcv_product_price', 'price_min_max' ); | |
function price_min_max( $args ){ | |
$args[ 'custom_attributes' ] = array( | |
'data-rules' => 'decimal|range[1,20]', | |
'data-error' => __( 'Price should be a number and between $1 and $20', 'wcvendors-pro' ) | |
); | |
return $args; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wcv_save_product_meta', 'wcv_custom_stock_opts' ); | |
function wcv_custom_stock_opts( $post_id ) { | |
update_post_meta( $post_id, '_manage_stock', 'yes' ); | |
update_post_meta( $post_id, '_backorders', 'no' ); | |
wc_update_product_stock( $post_id, wc_stock_amount( 1 ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* WC Vendors Pro - Add some new page links to the Pro Dashboard */ | |
function new_dashboard_pages( $pages ){ | |
$pages[] = array( 'label' => 'New Link', 'slug' => 'http://mysomelink.com' ); // Add stuff here | |
return $pages; | |
} | |
add_filter( 'wcv_pro_dashboard_urls', 'new_dashboard_pages' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* WC Vendors - Redirect even from wp-login.php for the role vendor */ | |
add_action( 'admin_init', 'wcvendors_wplogin_redirect' ); | |
function wcvendors_wplogin_redirect() { | |
if ( ! defined( 'DOING_AJAX' ) ) { | |
$current_user = wp_get_current_user(); | |
$role_name = $current_user->roles[0]; | |
if ( 'vendor' === $role_name ) { | |
wp_redirect( 'http://yoursite.com/dashboard' ); | |
} // if $role_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Code by Fervous | |
* WC Vendors - Shows a "My Products" tab in BuddyPress and then the vendors products in that tab | |
*/ | |
function my_bp_nav_adder() { | |
if (class_exists('WC_Vendors')) { | |
$wcv_profile_id = bp_displayed_user_id(); | |
$wcv_profile_info = get_userdata( bp_displayed_user_id() ); | |
if ( $wcv_profile_info->roles[0] == "vendor" ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* WC Vendors Pro - Remove shipping panel from single product page */ | |
remove_action( 'woocommerce_product_tabs', array( $wcvendors_pro->wcvendors_pro_shipping_controller, 'shipping_panel_tab'), 11, 2 ); | |
remove_action( 'woocommerce_product_meta_start', array( $wcvendors_pro->wcvendors_pro_vendor_controller, 'product_ships_from'), 9 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* WC Vendors Pro - Cart/Checkout Filter | |
* This is just an example of the WooCommerce checkout process and cart pages to "check" something and display an error of some | |
* sort. This code does nothing as it is, you'd have to write it inside the custom_checkout_filter function. Some | |
* notes are there to give you an idea on how to get data from the cart, and the WooCommerce notices function that | |
* shows a pretty box with a message. Have fun. | |
*/ | |
add_action( 'woocommerce_checkout_process', 'custom_checkout_filter' ); | |
add_action( 'woocommerce_before_cart' , 'custom_checkout_filter' ); | |
function custom_checkout_filter() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* WC Vendors Pro - My Custom Bank Fields */ | |
function store_bank_details( ){ | |
if ( class_exists( 'WCVendors_Pro' ) ){ | |
$key = '_wcv_custom_settings_bankname'; | |
$value = get_user_meta( get_current_user_id(), $key, true ); | |
// Bank Name | |
WCVendors_Pro_Form_Helper::input( array( | |
'id' => $key, | |
'label' => __( 'Banküberweisung als Auszahlungs Methode Ihres Provision verwenden', 'wcvendors-pro' ), | |
'placeholder' => __( 'Bank Name', 'wcvendors-pro' ), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* WC Vendors Pro - Custom "Ships From" code provided by @pronet | |
* https://www.wcvendors.com/help/topic/custom-ships-from-how-to/ | |
* Say you want to show more detailed location information under single product view “Ships From” section. | |
* This will show in addition the city and state/province. | |
*/ | |
function custom_ships_from(){ | |
global $post; | |
$vendor_id = WCV_Vendors::get_vendor_from_product( $post->ID ); | |
$town = get_user_meta( $vendor_id, '_wcv_store_city', true ); | |
$county = get_user_meta( $vendor_id, '_wcv_store_state', true ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The same type of code can be used for every field, these | |
two examples change the Product Title and Product Description | |
text to something else on the add/edit product form. Goes in | |
your themes functions.php file as always. ;) | |
add_filter('wcv_product_title', 'custom_wcv_product_title'); | |
function custom_wcv_product_title( $args ){ | |
$args['label'] = 'New Product Name Label'; | |
return $args; | |
} |