Skip to content

Instantly share code, notes, and snippets.

View ashokrane's full-sized avatar

Vishal Kothari ashokrane

View GitHub Profile
@ashokrane
ashokrane / show_custom_woocommerce_thank_you_by_variation_id.php
Last active March 13, 2018 11:39
Redirect to custom WooCommerce Thank You page based on product attribute id (variation id)
<?php
add_action( 'woocommerce_thankyou', 'redirect_product_attribute_based', 1 );
function redirect_product_attribute_based( $order_id ) {
$order = wc_get_order( $order_id );
foreach( $order->get_items() as $item ) {
// Add whatever variation id you want below here
if ( isset( $item[ 'variation_id' ] ) && $item[ 'variation_id' ] == 446 ) {
// change below to the URL that you want to send your customer to
wp_redirect( 'http://yoururl.com/custom-thank-you/' );
@ashokrane
ashokrane / shorten-woocommerce-product-name-in-abandon-cart-recovery-emails.php
Created January 24, 2018 07:16
How to shorten WooCommerce product name in Abandon cart recover email notification
<?php
add_filter( 'wcap_product_name', 'shorten_product_name_in_abandon_cart_emails', 10, 1 );
function shorten_product_name_in_abandon_cart_emails( $item_name ) {
if ( 'Rent a bicycle' == $item_name ) {
$item_name = 'Rent a bicy..';
}
return $item_name;
}