View functions.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
add_filter( 'woocommerce_add_to_cart_validation', 'wc_limit_one_per_order', 10, 2 ); | |
function wc_limit_one_per_order( $passed_validation, $product_id ) { | |
if ( 31 !== $product_id ) { | |
return $passed_validation; | |
} | |
if ( WC()->cart->get_cart_contents_count() >= 1 ) { | |
wc_add_notice( __( 'This product cannot be purchased with other products. Please, empty your cart first and then add it again.', 'woocommerce' ), 'error' ); | |
return false; | |
} |
View functions.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
/** | |
* Register term fields | |
*/ | |
add_action( 'init', 'register_attributes_url_meta' ); | |
function register_attributes_url_meta() { | |
$attributes = wc_get_attribute_taxonomies(); | |
foreach ( $attributes as $tax ) { | |
$name = wc_attribute_taxonomy_name( $tax->attribute_name ); |
View functions.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
/** | |
* Schedule the daily event if necessary. | |
*/ | |
function schedule_delete_expired_coupons() { | |
if ( ! wp_next_scheduled( 'delete_expired_coupons' ) ) { | |
wp_schedule_event( time(), 'daily', 'delete_expired_coupons' ); | |
} | |
} | |
add_action( 'init', 'schedule_delete_expired_coupons' ); |
View functions.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
/** | |
* Register term fields | |
*/ | |
add_action( 'init', 'register_vendor_custom_fields' ); | |
function register_vendor_custom_fields() { | |
add_action( WC_PRODUCT_VENDORS_TAXONOMY . '_add_form_fields', 'add_vendor_custom_fields' ); | |
add_action( WC_PRODUCT_VENDORS_TAXONOMY . '_edit_form_fields', 'edit_vendor_custom_fields', 10 ); | |
add_action( 'edited_' . WC_PRODUCT_VENDORS_TAXONOMY, 'save_vendor_custom_fields' ); | |
add_action( 'created_' . WC_PRODUCT_VENDORS_TAXONOMY, 'save_vendor_custom_fields' ); | |
} |
View functions.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
add_filter( 'body_class', 'add_preorder_class' ); | |
add_filter( 'post_class', 'add_preorder_class' ); | |
function add_preorder_class( $classes ) { | |
global $post; | |
$product = wc_get_product( $post->ID ); | |
if ( $product && 'yes' === get_post_meta( $product->get_id(), '_wc_pre_orders_enabled', true ) ) { | |
$classes[] = 'pre-order'; | |
} |
View functions.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
add_filter( 'woocommerce_countries_allowed_countries', 'wc_ban_russia' ); | |
function wc_ban_russia( $countries ) { | |
if ( isset( $countries['RU'] ) ) { | |
unset( $countries['RU'] ); | |
} | |
return $countries; | |
} |
View functions.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
add_filter( 'woocommerce_get_price_html', 'wc_edit_bookable_remove_from_price', 10, 2 ); | |
function wc_edit_bookable_remove_from_price( $html, $product ) { | |
if ( ! $product->is_type( 'booking' ) ) { | |
return $html; | |
} | |
return str_replace( 'From: ', '', $html ); | |
} |
View short-description-on-shop-page.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
/** | |
* Plugin Name: Show Short Description on the Shop Page | |
* Plugin URI: https://nicolamustone.blog/2016/12/01/show-products-short-description-shop-page/#comment-2119 | |
* Description: Shows the product's short description on the shop page with WooCommerce. | |
* Version: 1.0 | |
* Author: Nicola Mustone | |
* Author URI: https://nicolamustone.blog | |
*/ | |
add_action( 'woocommerce_after_shop_loop_item', 'woo_show_excerpt_shop_page', 5 ); |
View jquery.wc-custom.js
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
jQuery(document).ready(function ( $ ) { | |
$( 'button.load_customer_billing' ).off( 'click' ); | |
$( 'button.load_customer_billing' ).on( 'click', function() { | |
if ( window.confirm( woocommerce_admin_meta_boxes.load_billing ) ) { | |
// Get user ID to load data for | |
var user_id = $( '#customer_user' ).val(); | |
if ( ! user_id ) { | |
window.alert( woocommerce_admin_meta_boxes.no_customer_selected ); |
View functions.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
/** | |
* Add the Confirm Email Address field to the Billing chekcout form | |
*/ | |
add_filter( 'woocommerce_checkout_fields' , 'wc_custom_add_email_confirm_field_checkout' ); | |
function wc_custom_add_email_confirm_field_checkout( $fields ) { | |
$fields['billing']['billing_email_confirm'] = array( | |
'label' => __( 'Confirm Email Address', 'domain' ), | |
'required' => true, | |
'class' => array( 'form-row-wide' ), | |
'priority' => 120, |
NewerOlder