This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Display a product custom field within single product pages after the short description | |
function woocommerce_custom_field_example() { | |
if ( ! is_product() ) { | |
return; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remove the Billing VAT field from the checkout form only for Wholesalers. | |
*/ | |
function custom_override_checkout_fields( $fields ) { | |
if ( ! current_user_can( 'wholesalers' ) && isset( $fields['billing']['billing_vat'] ) ) { | |
unset( $fields['billing']['billing_vat'] ); | |
} | |
return $fields; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_before_add_to_cart_button', 'woo_remove_product_warranty', 9); | |
function woo_remove_product_warranty() { | |
global $warranty_cart; | |
remove_action( 'woocommerce_before_add_to_cart_button', array( $warranty_cart, 'show_product_warranty' ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* goes in theme functions.php or a custom plugin | |
**/ | |
// add item to cart on visit depending on cart total value | |
add_action( 'init', 'add_product_to_cart' ); | |
function add_product_to_cart() { | |
if ( ! is_admin() ) { | |
global $woocommerce; | |
$product_id = 2831; | |
$found = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#header .social {float:right;} | |
#header .social a { | |
filter: alpha(opacity=@opacity * 100); | |
-moz-opacity: 0.8; | |
-khtml-opacity: 0.8; | |
opacity: 0.8; | |
-webkit-transition: all ease-in-out 0.2s; | |
-moz-transition: all ease-in-out 0.2s; | |
-o-transition: all ease-in-out 0.2s; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woo_header_inside', 'woo_custom_social_links', 10 ); | |
function woo_custom_social_links () { | |
global $woo_options; | |
$settings = array( | |
'feed_url' => '', | |
'connect_rss' => '', | |
'connect_twitter' => '', | |
'connect_facebook' => '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Redirect users to custom URL based on their role after login | |
* | |
* @param string $redirect | |
* @param object $user | |
* @return string | |
*/ | |
function wc_custom_user_redirect( $redirect, $user ) { | |
// Get the first of all the roles assigned to the user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a vendor on account registration. | |
* | |
* @param int $customer_id | |
* @param array $new_customer_data | |
* @return boid | |
*/ | |
function wc_create_vendor_on_registration( $customer_id, $new_customer_data ) { | |
$username = $new_customer_data['user_login']; | |
$email = $new_customer_data['user_email']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add fields to new vendor form | |
add_action( 'shop_vendor_add_form_fields', 'custom_add_vendor_fields', 2, 1 ); | |
function custom_add_vendor_fields( $taxonomy ) { | |
?> | |
<div class="form-field"> | |
<label for="vendor_website"><?php _e( 'Vendor website' ); ?></label> | |
<input type="text" name="vendor_data[website]" id="vendor_website" class="vendor_fields" /><br/> | |
<span class="description"><?php _e( 'The vendor\'s website.' ); ?></span> | |
</div> | |
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Apply a different tax rate based on the user role. | |
*/ | |
function wc_diff_rate_for_user( $tax_class, $product ) { | |
if ( is_user_logged_in() && current_user_can( 'administrator' ) ) { | |
$tax_class = 'Zero Rate'; | |
} | |
return $tax_class; |
NewerOlder