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 ) { | |
$terms = wp_get_post_terms( $product_id, 'product_cat' ); | |
foreach ( $terms as $term ) $categories[] = $term->slug; | |
if ( in_array( 'clothes', $categories ) ) { // 'clothes' is the defined product category. Change this value to the slug of your choice. | |
return $passed_validation; | |
} | |
/* if ( 55 !== $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
/* | |
* Adds then moves Apple Pay button on the checkout page. | |
*/ | |
add_filter( 'wc_stripe_show_payment_request_on_checkout', '__return_true' ); | |
remove_action( 'woocommerce_checkout_before_customer_details', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_html' ), 1 ); | |
remove_action( 'woocommerce_checkout_before_customer_details', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_separator_html' ), 2 ); | |
add_action( 'woocommerce_after_checkout_form', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_html' ), 2 ); |
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_order_status_changed', 'wc_auto_complete_by_payment_method'); | |
function wc_auto_complete_by_payment_method($order_id) | |
{ | |
if ( ! $order_id ) { | |
return; | |
} | |
global $product; |
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_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 ); | |
function remove_add_to_cart_buttons() { | |
/*Removes add to cart buttons from shop, category, and home pages */ | |
if( is_product_category() || is_shop() || is_front_page()) { | |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); | |
} | |
/*Removes add to cart buttons from related products section */ | |
global $woocommerce_loop; |
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
/* | |
This snippet helps you add custom images (like "Secure Checkout") to single product pages. You can add it to your site at the bottom of your theme's `functions.php` file, or by using a Code Snippets Plugin: https://wordpress.org/plugins/code-snippets/ | |
The end result would look like this: https://d.pr/i/nUk1Bm | |
*/ | |
function woo_add_security_image() { | |
echo '<img src="https://example.com/security-image-url.jpg" />'; // Replace the URL here with the URL of your image. | |
/* Remove the `//` Comments and update the URL(s) below if you would like to add multiple images to your single product page */ |
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_validate_postcode','woo_validate_belgium_postcode',10,3); | |
function woo_validate_belgium_postcode($valid, $postcode, $country){ | |
if($country=="BE") | |
$valid = (bool) preg_match( '/^([0-9]{4})$/', $postcode ); | |
// Checks your postcode to seee if it matches belgium (4 digits). If not, it will reject validation. | |
return $valid; | |
} |
OlderNewer