Skip to content

Instantly share code, notes, and snippets.

View fervous's full-sized avatar

Anna fervous

View GitHub Profile
@fervous
fervous / functions.php
Created March 29, 2018 03:01 — forked from digitalchild/functions.php
Disable Add Products in WC Vendors Pro if vendor hasn't connected stripe account
<?php
/**
* This code will disable add product functionality until the stripe connected account is active for the vendor. This will also disable quick links on the main dashboard page.
*
*/
// Only enable if the Stripe gateway is actually active
if ( class_exists('WC_Gateway_Stripe_Connect') ) {
// Hook into the dashboard
@fervous
fervous / functions.php
Created September 24, 2017 19:24 — forked from digitalchild/functions.php
Change Navigation tab order in WC Vendors Pro
<?php
// Add this to your themes functions.php to change the order, rearrage the lines. First line is first item, last is last etc.
add_filter( 'wcv_dashboard_pages_nav', 'change_nav_order');
function change_nav_order( $pages ){
$new_nav_order = array();
$new_nav_order['dashboard_home'] = $pages['dashboard_home'];
@fervous
fervous / gist:fa6f5896af1f0389a7e547a791ddaebf
Created August 7, 2017 22:22 — forked from jetlej/gist:a8498b00efd908325719
Overwrite Wordpress SEO meta description for WC Vendors shop page
// Overwrite meta description for vendor pages
function overwrite_vendor_meta($desc) {
// Return the default value if we're not on a vendor shop page
if(!WCV_Vendors::is_vendor_page()) return $desc;
// Get the vendor description and return it
$vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
$vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
$desc = get_user_meta( $vendor_id, 'pv_shop_description', true );
//WP Query to get all bookable products of a vendor
$args = array(
'post_type' => 'product',
'author' => $vendor,
'meta_query' => array(
array(
'key' => '_wc_booking_availability',
'compare' => 'EXISTS',
),
@fervous
fervous / functions.php
Last active May 17, 2017 01:47 — forked from bentasm1/functions.php
WC Vendors - Forcing all new registrations to be Vendors ( default ) if my-account registration is used
/* By default Registrations to your site using the My Account = Vendor role, rather than the Customer role */
add_filter( 'woocommerce_new_customer_data', 'custom_woocommerce_new_customer_data' );
function custom_woocommerce_new_customer_data( $data ){
$data['role'] = 'vendor'; // the new default role
return $data;
}
@fervous
fervous / functions.php
Created May 16, 2017 03:29 — forked from digitalchild/functions.php
Remove the shipping method title from WC Vendors Pro
<?php
// Remove the Vendor shop name from the shipping package title
add_filter( 'wcv_vendor_shipping_package_title', 'remove_shipping_title' );
function remove_shipping_title( $title ){
return '';
}
?>
@fervous
fervous / product-edit.php
Created May 10, 2017 22:26 — forked from digitalchild/product-edit.php
WC Vendors Pro - Replace product descriptions with wordpress editor
<?php
// This code goes in the product-edit.php override template for wc-vendors pro
// Replace WCVendors_Pro_Product_Form::description( $object_id, $product_description );
// with
$product_description_args = array(
'editor_height' => 200,
'media_buttons' => true,
'teeny' => true,
@fervous
fervous / functions.php
Created March 22, 2017 23:44 — forked from digitalchild/gist:3b75a5ff599357f0a4b3
Vendor Commission based on Category fixed price
<?php
add_filter( 'wcv_commission_rate', 'my_wcv_commission_rate', 10, 4 );
function my_wcv_commission_rate( $commission, $product_id, $product_price, $order ) {
$terms = get_the_terms( $product_id, 'product_cat' );
// Loop through the categories
// It will break on the first category assigned
foreach ( $terms as $term ) {
@fervous
fervous / functions.php
Created March 10, 2017 03:53 — forked from digitalchild/functions.php
Change product title to date selector in WC Vendors Pro
<?php
// Put this in your themes functions.php
add_filter( 'wcv_product_title', 'product_title_date' );
function product_title_date( $args ){
$args[ 'class' ] = 'wcv-datepicker';
return $args;
}
@fervous
fervous / functions.php
Created March 3, 2017 21:59 — forked from digitalchild/functions.php
Display a notice if the vendor hasn't connected their stripe account
<?php
// Add this to your themes functions.php this will not work with free only the pro dashboard.
add_action( 'wcv_pro_before_dashboard', 'add_stripe_notice' );
function add_stripe_notice( ){
$stripe_token = get_user_meta( get_current_user_id(), '_stripe_connect_access_key' , true );
if ( ! isset( $stripe_token ) ){
echo '<div class="woocommerce-error"><p>Connect your stripe account to accept payments thanks!</p></div>';
}