Created
May 25, 2021 12:00
-
-
Save slavapas/b7e6cf8419a8cc7ada0a78b58064958b to your computer and use it in GitHub Desktop.
WooCommerce - Add additional content bellow the Product Title on the Cart Page
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 | |
function alt_message() { | |
return '<p class="backorder_notification backorder_notification_custom">Please allow 20 days for delivery of this item</p>'; | |
} | |
function backorder_text($availability) { | |
$altmessage = alt_message(); | |
foreach ($availability as $i) { | |
$availability = str_replace('Available on backorder', $altmessage, $availability); | |
} | |
return $availability; | |
} | |
add_filter('woocommerce_get_availability', 'backorder_text'); | |
function woocommerce_custom_cart_item_name($_product_title, $cart_item, $cart_item_key) { | |
$altmessage = alt_message(); | |
if ($cart_item['data']->backorders_require_notification() && $cart_item['data']->is_on_backorder($cart_item['quantity'])) { | |
$_product_title .= __(' - ' . $altmessage, 'woocommerce'); | |
} | |
return $_product_title; | |
} | |
add_filter('woocommerce_cart_item_name', 'woocommerce_custom_cart_item_name', 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment