Skip to content

Instantly share code, notes, and snippets.

View MarkKevin08's full-sized avatar

MarkKevin08

View GitHub Profile
@MarkKevin08
MarkKevin08 / function.php
Created November 5, 2019 06:16
Add shipping policy to cart and checkout
add_action('woocommerce_cart_totals_before_order_total', 'wcv_display_shipping_policy');
add_action('woocommerce_review_order_before_shipping', 'wcv_display_shipping_policy');
function wcv_display_shipping_policy() {
$product = gastronomy_get_productID_from_cart();
$vendor_id = get_post_field( 'post_author', $product);
$vendor_meta = array_map( function( $a ){ return $a[0]; }, get_user_meta( $vendor_id ) );
$vendor_shipping = array_key_exists('_wcv_shipping', $vendor_meta ) ? unserialize( $vendor_meta['_wcv_shipping'] ) : self::get_shipping_defaults();
@MarkKevin08
MarkKevin08 / gist:779a7cae79f2c0e5bf3191d39db29469
Created November 10, 2019 23:50
Change "View Policies" tab
add_filter( 'woocommerce_product_tabs', function( $tabs ) {
if( isset( $tabs['policies'] ) ) {
$tabs['policies']['title'] = 'New title';
}
return $tabs;
}, 30 );
@MarkKevin08
MarkKevin08 / function.php
Created November 28, 2019 23:20
"Sold Individual" default
function default_no_quantities( $individually, $product ){
$individually = true;
return $individually;
}
add_filter( 'woocommerce_is_sold_individually', 'default_no_quantities', 10, 2 );
@MarkKevin08
MarkKevin08 / function.php
Last active March 11, 2021 05:27
Change sold by link
add_filter( 'wcv_sold_by_link', 'vendor_shop_url_update', 11, 2 );
function vendor_shop_url_update( $sold_by, $vendor_id ) {
// Recreate the link and anchor text.
if ( WCV_Vendors::is_vendor( $vendor_id ) ) {
$class = isset( $css_class ) ? 'class="' . $css_class . '"' : '';
$sold_by_label = WCV_Vendors::get_vendor_sold_by( $vendor_id );
// Change the link here.
$shop_page_url = WCV_Vendors::get_vendor_shop_page( $vendor_id );
$sold_by = sprintf( '<a href="%s" %s>%s</a>', $shop_page_url, $class, $sold_by_label );
}
@MarkKevin08
MarkKevin08 / function.php
Last active September 11, 2020 05:48
//inventory management default to managed and only 1 stock
add_filter( 'wcv_product_sold_individually', 'change_default_sold_individually' );
function change_default_sold_individually() {
$field['post_id'] = $post_id;
$field['id'] = '_sold_individually';
$field['wrapper_class'] = 'show_if_simple show_if_variable';
$field['label'] = __( 'Sold Individually', 'wcvendors-pro' );
$field['desc_tip'] = 'true';
$field['description'] = __( 'Enable this to only allow one of this item to be bought in a single order', 'wcvendors-pro' );
$field['type'] = 'checkbox';
@MarkKevin08
MarkKevin08 / CSS
Created December 11, 2020 09:39
Commonly asked CSS snippet for WC Vendors
/******Store Header data******/
/*Remove description*/
.wcv-store-header.header-modern .desc {
display: none;
}
/*Remove Address/other blocks*/
.phone{
display: none;
@MarkKevin08
MarkKevin08 / function.php
Created December 19, 2020 08:50
change dashboard slug
add_filter( 'wcv_pro_dashboard_urls', 'change_slugs' );
function change_slugs($args) {
$args['product']['slug'] = 'add-custom-slug';
return $args;
}
@MarkKevin08
MarkKevin08 / fuction.php
Created December 31, 2020 10:04
Flat rate - QTY auto checked
add_filter( 'wcv_product_shipping_fee_national_qty', 'change_default_product_shipping_fee_national_qty' );
function change_default_product_shipping_fee_national_qty() {
$field['id'] = '_shipping_fee_national_qty';
$field['label'] = __( 'Charge once per product for national shipping, even if more than one is purchased.', 'wcvendors-pro' );
$field['type'] = 'checkbox';
$field['value'] = 'yes';
$field['class'] = 'wcv-disable-national-input'; // This checks the checkbox
return $field;
<?php
/**
* The Template for displaying the modern store header
*
* Override this template by copying it to yourtheme/wc-vendors/store
*
* @package WCVendors_Pro
* @version 1.6.2
*/
@MarkKevin08
MarkKevin08 / function.php
Created February 13, 2021 06:30
Re-orders the policy tab contents
add_filter( 'wcv_product_policy_tab_content_args', 'change_policy_order');
function change_policy_order($post){
$new_policies = array();
$new_policies['shipping'] = $post['shipping'];
$new_policies['return'] = $post['return'];
$new_policies['terms'] = $post['terms'];
$new_policies['privacy'] = $post['privacy'];