Skip to content

Instantly share code, notes, and snippets.

@aaronkine
aaronkine / gist:123bde79af7f43f11c7eb484d402298d
Created November 7, 2016 01:51
Hide Toolbar for non Admins
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
@aaronkine
aaronkine / functions.php and product-edit.php
Last active November 2, 2016 21:22
Add checkbox and select dropdown to set Commission when editing product
// This changes the Product Commission to "Percentage". You can change it to Fixed or anything else. just edit the meta key value (wcv_commission_type)
// This also adds a checkbox in WooCommerce--> Product--> General. The Code to add the same checkbox to the front end form producty-edit.php (see below)
// NOTE: When Commission is set per product that value goes to the vendor. This is oposite when setting Commission in WC Vendors--> Settings
// WC Vendors--> Settings Commission set to 90 is the same as a vendors product set to 10.
function update_product_commission ($post_id) {
$wcv_percentage_to_pay = get_post_meta( $post_id, '_wcv_custom_product_percentage_to_vendor', true );
$give_to_afs = isset( $_POST['give_product_commission'] ) ? 'yes' : 'no';