Skip to content

Instantly share code, notes, and snippets.

@bentasm1
bentasm1 / functions.php
Created November 3, 2015 22:43 — forked from digitalchild/functions.php
Change the Pro Dashboard Date Range
<?php
// Change the start date
// from 1 year ago to 1 week ago
add_filter('wcv_dashboard_start_date', 'dashboard_start_date' );
function dashboard_start_date() {
return '-1 week';
}
// Change the end date
@bentasm1
bentasm1 / functions.php
Created November 3, 2015 22:34 — forked from digitalchild/functions.php
Change dashboard date range
<?php
add_filter('wcv_dashboard_start_date', 'dashboard_start_date' );
function dashboard_start_date() {
return '-1 week';
}
@bentasm1
bentasm1 / product-edit.php
Created October 28, 2015 21:42 — 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,
@bentasm1
bentasm1 / functions.php
Created October 10, 2015 15:24 — forked from digitalchild/functions.php
Change the Add Product URL on Pro Vendor dashboard
<?php
// Change the "Add Product" button url to the back end.
add_filter('wcv_add_product_url', 'new_add_product_url');
function new_add_product_url(){
return admin_url('post-new.php?post_type=product');
}
?>
// 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 );
@bentasm1
bentasm1 / functions.php
Last active January 20, 2022 22:52 — forked from kloon/functions.php
Set WooCommerce Tax Exemption based on user role
<?php
add_filter( 'init', 'wc_tax_exempt_user_roles' );
function wc_tax_exempt_user_roles() {
if ( ! is_admin() ) {
global $woocommerce;
if ( current_user_can('wholesaler') || current_user_can('distributor') ) {
$woocommerce->customer->set_is_vat_exempt(true);
} else {
$woocommerce->customer->set_is_vat_exempt(false);
}
@bentasm1
bentasm1 / functions.php
Last active August 29, 2015 14:09 — forked from kloon/functions.php
Add text after product price
<?php
// Add R xx.xx per KG
add_action( 'woocommerce_price_html', 'wc_custom_price', 10, 2 );
function wc_custom_price( $price, $product ) {
return sprintf( __( '%s per KG', 'woocommerce' ), woocommerce_price( $product->get_price() ) );
}
?>