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_email_header', 'add_email_header', 20 ); | |
function add_email_header() { | |
echo '<h2>My Heading</h2>'; | |
echo '<p>Add content here</p>'; | |
} |
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( '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'; | |
} |
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 | |
/** | |
* Sets the product default price to 10. Only works once, if the price is not specified. | |
* | |
* @param int $post_id | |
* @param object $post | |
*/ | |
function set_product_default_price( $post_id, $post ) { | |
$product = wc_get_product( $post_id ); | |
$already_set = get_post_meta( $post_id, '_set_default_price', true ); |
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 the theme credit | |
* | |
* @since 1.0.0 | |
* @return void | |
*/ | |
function storefront_credit() { | |
?> | |
<div class="site-info"> |
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( 'wp_discord_post_is_new_post', 'wp_discord_post_limit_by_category' ); | |
function wp_discord_post_limit_by_category( $post ) { | |
return has_category( array( 'Category 1', 'Category 2' ), $post ); | |
} |
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( 'wp_discord_post_is_new_post', 'wp_discord_post_limit_by_category' ); | |
function wp_discord_post_limit_by_category( $post ) { | |
return has_category( 'Your Category Name', $post ); | |
} |
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_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; |
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_order_details_after_order_table', 'post_sale_cross_sell' ); | |
function post_sale_cross_sell( $order ) { | |
$cross_sells = array(); | |
$in_order = array(); | |
foreach ( $order->get_items() as $item ) { | |
$product_id = $order->get_item( $item )->get_product_id(); | |
$product = wc_get_product( $product_id ); | |
$cross_sells = array_merge( $product->get_cross_sell_ids(), $cross_sells ); |
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 | |
// Delete Expired Coupons that have an expiration date set and are not from AutomateWoo | |
add_action('delete_expired_coupons_hook', 'delete_expired_coupons_action'); | |
function delete_expired_coupons_action() { | |
$query_args = [ | |
'fields' => 'ids', | |
'post_type' => 'shop_coupon', | |
'post_status' => 'any', | |
'posts_per_page' => -1, | |
'orderby' => 'date', |
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_cart_coupon', 'woocommerce_empty_cart_button' ); | |
function woocommerce_empty_cart_button() { | |
echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" class="button" title="' . esc_attr( 'Empty Cart', 'woocommerce' ) . '">' . esc_html( 'Empty Cart', 'woocommerce' ) . '</a>'; | |
} |