Last active
November 1, 2021 12:19
-
-
Save damiencarbery/41c4a93503c9bb3c6c9c48a6d569f6d5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/* | |
Plugin Name: WooCommerce - Free Shipping Notice | |
Plugin URI: http://www.damiencarbery.com | |
Description: Add note about free shipping for all except one product. | |
Author: Damien Carbery | |
Version: 0.1 | |
*/ | |
$exempt_product_id = array( 24, 1968 ); | |
add_action( 'woocommerce_after_shop_loop_item', 'wfsn_free_shipping_notice_archive_7', 7 ); | |
function wfsn_free_shipping_notice_archive_7() { | |
global $post; | |
global $exempt_product_id; | |
if (in_array( $post->ID, $exempt_product_id ) == false) { | |
echo '<p>woocommerce_after_shop_loop_item Priority 7; Product ID: ', $post->ID, '</p>'; | |
} | |
} | |
add_action( 'woocommerce_after_shop_loop_item', 'wfsn_free_shipping_notice_archive_15', 15 ); | |
function wfsn_free_shipping_notice_archive_15() { | |
global $post; | |
global $exempt_product_id; | |
if (in_array( $post->ID, $exempt_product_id ) == false) { | |
echo '<p>woocommerce_after_shop_loop_item Priority 15; Product ID: ', $post->ID, '</p>'; | |
} | |
} | |
add_action( 'woocommerce_single_product_summary', 'wfsn_free_shipping_notice_single_25', 25 ); | |
function wfsn_free_shipping_notice_single_25() { | |
global $post; | |
global $exempt_product_id; | |
if (in_array( $post->ID, $exempt_product_id ) == false) { | |
echo '<p><strong>woocommerce_single_product_summary Priority 25; Product ID: ', $post->ID, '</strong></p>'; | |
} | |
} | |
add_action( 'woocommerce_single_product_summary', 'wfsn_free_shipping_notice_single_60', 60 ); | |
function wfsn_free_shipping_notice_single_60() { | |
global $post; | |
global $exempt_product_id; | |
if (in_array( $post->ID, $exempt_product_id ) == false) { | |
echo '<p><strong>woocommerce_single_product_summary Priority 60; Product ID: ', $post->ID, '</strong></p>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Change $exempt_product_id to an array and change the test to in_array().