Skip to content

Instantly share code, notes, and snippets.

View ashokrane's full-sized avatar

Vishal Kothari ashokrane

View GitHub Profile
@ashokrane
ashokrane / seasonal-addon-price-on-cart-checkout-page.php
Created January 19, 2022 13:05
Seasonal Addon Price on Cart & Checkout page
function bkap_woocommerce_cart_item_subtotal( $product_subtotal, $cart_item, $cart_item_key ) {
if ( isset( $cart_item['bkap_booking'] ) ) {
$booking = $cart_item['bkap_booking'][0];
if ( isset( $booking[ 'hidden_date_checkout' ] ) ) {
$checkin_date_str = strtotime( $booking[ 'hidden_date' ] );
$checkout_date_str = strtotime( $booking[ 'hidden_date_checkout' ] );
$checkin_date = date( 'Y-m-d', $checkin_date_str );
$checkout_date = date( 'Y-m-d', $checkout_date_str );
@ashokrane
ashokrane / show_custom_text_woocommerce_thank_you_by_variation_id.php
Created March 13, 2018 11:41
Print custom text on WooCommerce Thank You page based on product attribute id (variation id)
<?php
add_action( 'woocommerce_thankyou', 'show_custom_text_by_variation_id', 1 );
function show_custom_text_by_variation_id( $order_id ) {
$order = wc_get_order( $order_id );
foreach( $order->get_items() as $item ) {
// Add whatever variation id you want below here. My attributes are Cheddar, Mozarella & Swiss
if ( isset( $item[ 'variation_id' ] ) && $item[ 'variation_id' ] == 446 ) {
echo 'Thank you for choosing Cheddar cheese. Enjoy your Sandwich!<br/>';
}