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 | |
/** | |
* @template Sell to Specific States/Provinces/Regions with WooCommerce | |
* @author Nicola Mustone | |
* @author_url https://nicolamustone.blog/2014/12/08/sell-in-specific-states-with-woocommerce/ | |
* @tested-up-to WooCommerce 8.4.X | |
*/ | |
function wc_sell_only_states( $states ) { | |
$states['US'] = array( | |
'CA' => __( 'California', 'woocommerce' ), |
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 | |
/** | |
* @template Custom Product Vendor Catalog Page | |
* @author Nicola Mustone | |
* @author_url https://nicolamustone.blog/2014/10/15/show-custom-template-vendor-shop-pages/ | |
* @tested-up-to WooCommerce 8.4.X | |
*/ | |
defined( 'ABSPATH' ) || exit; |
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 | |
/** | |
* @snippet Get Related Products by Attributes | |
* @author Nicola Mustone | |
* @author_url https://nicolamustone.blog/2023/12/21/improve-woocommerce-related-products-recommendations/ | |
* @tested-up-to WooCommerce 8.4.X | |
*/ | |
add_filter( 'woocommerce_related_products', 'nm_realted_products_by_attributes', 10, 3 ); | |
function nm_realted_products_by_attributes( $related_posts, $product_id, $args ) { | |
$product = wc_get_product( $product_id ); |
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
li.product .short-description { | |
text-align: left; | |
color: #333333; | |
} |
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 | |
add_filter( 'woocommerce_continue_shopping_redirect', 'custom_continue_shopping_redirect' ); | |
function custom_continue_shopping_redirect( $default ) { | |
// Example condition 1: Redirect to Home | |
if ( /* your condition for Home */ ) { | |
return home_url(); // Redirects to the Home page | |
} | |
// Example condition 2: Redirect to Shop | |
if ( /* your condition for Shop */ ) { |
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
body { | |
-webkit-user-select: none; /* Safari */ | |
-moz-user-select: none; /* Firefox */ | |
-ms-user-select: none; /* IE10+/Edge */ | |
user-select: none; /* Standard */ | |
} |
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 | |
add_action( 'woocommerce_checkout_process', 'automatic_validation_eu_vat' ); | |
function automatic_validation_eu_vat() { | |
$vat = str_replace( array( ' ', '.', '-', ',', ',' ), '', wc_clean( $_POST['billing_vat'] ) ); | |
if ( ! empty( $vat ) ) { | |
$response = wp_remote_get( "http://ec.europa.eu/taxation_customs/vies/vatResponse.html?ms=" . substr( $vat, 0, 2 ) . "&iso=" . substr( $vat, 2 ) ); | |
if ( is_wp_error( $response ) ) { | |
wc_add_notice( 'There was a problem connecting to the VAT validation service. Please try again later.', 'error' ); | |
} else { |
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 | |
add_filter( 'woocommerce_structured_data_product', 'conditional_identifier_exists_false', 10, 2 ); | |
function conditional_identifier_exists_false( $markup, $product ) { | |
// Replace 'your-category-slug' with the actual slug of the category you want to target. | |
$target_category_slug = 'your-category-slug'; | |
if ( has_term( $target_category_slug, 'product_cat', $product->get_id() ) ) { | |
$markup['identifier_exists'] = 'no'; | |
} | |
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 | |
add_filter( 'woocommerce_structured_data_product', 'add_identifier_exists_false' ); | |
function add_identifier_exists_false( $markup ) { | |
$markup['identifier_exists'] = 'no'; | |
return $markup; | |
} |
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 | |
add_action( 'woocommerce_after_order_itemmeta', 'admin_order_add_product_info_and_link', 10, 3 ); | |
function admin_order_add_product_info_and_link( $item_id, $item, $_product ) { | |
if ( ! $_product ) return; | |
$product_link = get_permalink( $_product->get_id() ); | |
$attributes_to_display = ['slug_1', 'slug_2', 'slug_3']; // Specify the attribute slugs you want to display | |
$target_product = $_product; | |
if ($_product->is_type('variation')) { |
NewerOlder