Skip to content

Instantly share code, notes, and snippets.

<?php
add_action( 'woocommerce_review_order_after_order_total', 'ts_review_order_after_order_total', 10 );
function ts_review_order_after_order_total(){
echo '<h2>woocommerce_review_order_after_order_total</h2>';
}
<?php
add_filter( 'woocommerce_package_rates', 'my_hide_shipping_when_free_is_available' );
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach( $rates as $rate_id => $rate ) {
if( 'free_shipping' === $rate->method_id ) {
$free[ $rate_id ] = $rate;
break;
<?php
add_action('woocommerce_checkout_order_review', 'ts_checkout_order_review');
function ts_checkout_order_review() {
echo '<h2>woocommerce_checkout_order_review</h2>';
}
<?php
add_action('woocommerce_checkout_before_order_review_heading', 'ts_checkout_before_order_review_heading');
function ts_checkout_before_order_review_heading() {
echo '<h2>woocommerce_checkout_before_order_review_heading</h2>';
}
<?php
add_action('woocommerce_after_checkout_registration_form', 'ts_after_checkout_registration_form');
function ts_after_checkout_registration_form() {
echo '<h2>woocommerce_after_checkout_registration_form</h2>';
}
<?php
add_action('woocommerce_checkout_shipping', 'ts_checkout_shipping');
function ts_checkout_shipping() {
echo '<h2>woocommerce_checkout_shipping</h2>';
}
<?php
add_action('woocommerce_before_checkout_registration_form', 'ts_checkout_billing');
function ts_checkout_billing() {
echo '<h2>woocommerce_before_checkout_registration_form</h2>';
}
<?php
add_action('woocommerce_checkout_billing', 'ts_checkout_billing');
function ts_checkout_billing() {
echo '<h2>woocommerce_checkout_billing</h2>';
}
<?php
add_action( 'woocommerce_before_main_content', 'before_main_content' );
function before_main_content() {
echo "<div>
<h1>Get a discount of 10% on any item</h1>
</div>";
}
<?php
add_filter( 'woocommerce_coupons_enabled','ts_hide_coupon_field_on_cart' );
function ts_hide_coupon_field_on_cart( $enabled ) {
$product_categories = array('hd', 'led');
$cart = WC()->cart->get_cart();
foreach ( $cart as $id => $cart_item ) {
$_product = wc_get_product($cart_item[ 'data' ]->get_id() );