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 - Looks at the cart and, if something in the cart is sold by a vendor who hasn’t saved | |
* his PayPal account address in his Dashboard>Settings>Payment area, then the PayPal AP gateway included | |
* with WC Vendors is removed from the list of available gateways at checkout. | |
* Props to @dvrcthewrld for the code | |
*/ | |
function ps_filter_gateways($gateways) { | |
if ( is_checkout_pay_page() ) { | |
global $wp; | |
if ( isset( $wp->query_vars['order-pay'] ) ) { |
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 | |
// Hijack vendor menu to insert view store link. | |
function wcv_store_menu_link( $items, $args ) { | |
if ( WCV_Vendors::is_vendor( get_current_user_id() ) ) { | |
// Only insert the link in the menu you want based on the menu slug you define below. | |
// In this example a menu has been created called 'Vendor Menu' that has the menu slug vendor-menu | |
// This link will be the last link in the vendor menu |
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
Step 1: wp-admin > settings > general > change default role to Vendor. This makes it work with wp-login.php | |
Step 2: To force WooCommerce to call all new /my-account/ and /checkout/ users to be vendors, add this to themes functions.php: | |
/* WC Vendors - Make all new WooCommerce registrants vendors */ | |
add_filter( 'woocommerce_new_customer_data', 'wcv_everyone_can_sell'); | |
function wcv_everyone_can_sell($new_customer_data){ | |
$new_customer_data['role'] = 'vendor'; | |
return $new_customer_data; |
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 another file uploader to upload a file with the ID in a meta key */ | |
function custom_wcv_file_uploader( ){ | |
$value = get_user_meta( get_current_user_id(), 'wcv_custom_product_file1', true ); // Must match meta key used in line 8 | |
WCVendors_Pro_Form_Helper::file_uploader( array( | |
'header_text' => __('File uploader', 'wcvendors-pro' ), | |
'add_text' => __('Add file', 'wcvendors-pro' ), | |
'remove_text' => __('Remove file', 'wcvendors-pro' ), | |
'image_meta_key' => 'wcv_custom_product_file1', // Must match meta key used in line 3 | |
'save_button' => __('Add file', 'wcvendors-pro' ), | |
'window_title' => __('Select an Image', '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
Gives vendors an option to allow gift wrapping. Requires https://wordpress.org/plugins/woocommerce-product-gift-wrap/ | |
// Goes in your product-edit.php template, anywhere you see fit for it | |
WCVendors_Pro_Form_Helper::input( | |
array( | |
'post_id' => $object_id, | |
'id' => 'wcv_custom_product_gift_wrapper_enable', | |
'label' => __( 'Let buyer choose product to be wrapped?', 'wcvendors-pro' ), | |
'type' => 'checkbox' |
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 | |
// WC Vendors Pro vendors list uses the same layout as the default woocommerce pagination | |
// IF your theme is overriding the layout of the pagination links then you can use the following snippets (modified for your theme) | |
// to make the vendor list pagination links wrap with your theme wrappers and styles. | |
// Pagination wrapper opening tag | |
add_filter( 'wcv_pagination_before', 'wcv_pagination_before_wrapper' ); | |
function wcv_pagination_before_wrapper( $html ) { | |
return '<div class="somethign else">'; |
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 -- No % for commission, just a tiered fee structure */ | |
add_filter( 'wcv_commission_rate', 'my_wcv_commission_rate', 10, 5 ); | |
function my_wcv_commission_rate( $commission, $product_id, $product_price, $order, $qty ) { | |
// First, reduce price to qty1 to do calculations | |
$product_price = $product_price / $qty; | |
// Second, run through the price and apply the right commission fee | |
if ( $product_price > 48.99 ) { | |
$commission_fee = 3.36; |
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 - A quick action for showing a string of text on the | |
* my account page for a general terms and conditions for all users | |
* not just vendors. */ | |
add_action( 'woocommerce_register_form', 'wcvendors_extra_myaccount_text' ); | |
function wcvendors_extra_myaccount_text() { | |
echo '<strong>Important</strong> -- By registering to this site you agree to our <a href="/whatever/" target="top">General Terms and Conditions</a>.'; | |
} |
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 - Show country code from vendors store on single product pages */ | |
add_action('woocommerce_product_meta_start', 'wcv_show_vendor_country'); | |
function wcv_show_vendor_country() { | |
$author_id = get_the_author_id(); | |
$wcv_store_country = get_user_meta( $author_id, '_wcv_store_country', true); | |
echo 'Ships From: ' . $wcv_store_country; | |
echo '<br>'; // Remove this line if you dont need the extra line break | |
} |
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 - Rename the "Shipping" tab on the front end single product pages to something else */ | |
add_filter('wcv_shipping_tab', 'custom_wcv_shipping_tab'); | |
function custom_wcv_shipping_tab() { | |
$args['title'] = 'My New Shipping Tab Label'; | |
return $args; | |
} |