Skip to content

Instantly share code, notes, and snippets.

View digitalchild's full-sized avatar

Jamie Madden digitalchild

View GitHub Profile
@digitalchild
digitalchild / hijackmenu.php
Created October 24, 2014 11:25
Hijack Wordpress menu to insert shop link
<?php
// Hijack menu to insert vendor shop link.
add_filter('wp_nav_menu_items', 'vendor_shop_link', 10, 2);
function vendor_shop_link($items, $args) {
$wcv_settings = get_option('wc_prd_vendor_options');
$wcv_perm = $wcv_settings['vendor_shop_permalink'];
@digitalchild
digitalchild / gist:35d4a33509c2c4dcd9ee
Created December 18, 2014 14:33
WC Vendors - Vendor Shop Name as Full Name
/**
* Format WordPress User's "Display Name" to Full Name on Login
* ------------------------------------------------------------------------------
*/
add_action( 'wp_login', 'wpse_9326315_format_user_display_name_on_login' );
function wpse_9326315_format_user_display_name_on_login( $username ) {
$user = get_user_by( 'login', $username );
@digitalchild
digitalchild / gist:327630fd1c92c2be3a2e
Created January 21, 2015 06:00
Disable WordPress admin bar
<?php
/**
* Place this in your functions.php
*/
if ( is_user_logged_in() ) {
add_filter('show_admin_bar', '__return_false');
}
?>
@digitalchild
digitalchild / gist:8caf33ac79626ed2e71c
Created February 20, 2015 07:34
Add Profile fields
// Save fields
add_action( 'personal_options_update', 'pv_save_merchant_id' );
add_action( 'edit_user_profile_update', 'pv_save_merchant_id' );
// Display Fields
add_action( 'show_user_profile', 'pv_add_custom_merchant_id_field' );
add_action( 'edit_user_profile', 'pv_add_custom_merchant_id_field' );
@digitalchild
digitalchild / wcv_vendors_menu
Created February 25, 2015 11:10
WC Vendors Dynamic Menu
<?php
// Place this in your themes functions.php
// This will put the menu item in your primary menu. Change the theme location if you want to change which menu this goes in.
// Hook into the nav menu items
add_filter( 'wp_nav_menu_items', 'wcv_vendors_menu', 10, 2 );
// Generate the menu
function wcv_vendors_menu ( $items, $args ) {
@digitalchild
digitalchild / wcv_pps_wpuf
Created February 25, 2015 11:32
WC Vendors Per Product Shipping WPUF Hook code
<?php
/**
* wcv_pps_shipping_costs
*
* This is fired on save & edit of a product
*
*/
function wcv_pps_shipping_costs ( $post_id ){
@digitalchild
digitalchild / gist:101006d053654ad438c6
Last active August 29, 2015 14:20
Vendor ID on WC Vendors shop page
<?php
//
$vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
$vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
$args = array(
post_type => 'product_variation',
post_author => $vendor_id
);
<?php
sprintf( __( 'Total commission currently due: %d. <a href="%s">View details</a>.', 'wcvendors' ), !function_exists( 'woocommerce_price' ) ? $total_due : woocommerce_price( $total_due ), '?page=pv_admin_commissions' ) .
?>
@digitalchild
digitalchild / gist:16baaa9da4eeaf13e05f
Created May 28, 2015 03:01
Pseudo Code for removing a product type.
<?php
add_filter( 'product_type_selector', 'remove_listing_package');
// $product type is an array of product it containts the following:
//
// $product_type_selector = apply_filters( 'product_type_selector', array(
// 'simple' => __( 'Simple product', 'wcvendors-pro' ),
// 'grouped' => __( 'Grouped product', 'wcvendors-pro' ),
// 'external' => __( 'External/Affiliate product', 'wcvendors-pro' ),
@digitalchild
digitalchild / gist:3b75a5ff599357f0a4b3
Created May 28, 2015 03:27
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 ) {