'Custom product note on checkout but only to products with specific stock status
I have created a custom stock status for preorders.
How can I make custom notes appear on checkout next to products, but only one with the status 'Preorder'?
I mean something like this. https://i.stack.imgur.com/ZRNDO.jpg
I want it to be something like:
This is a preorder. Shipping after the release (date).
And date will display value of product attribute with 'release' slug.
Solution 1:[1]
add_filter('woocommerce_cart_item_name', 'woocommerce_cart_item_extra', 10, 3);
function woocommerce_cart_item_extra($item_name, $cart_item, $cart_item_key) {
if ('preorder' === $cart_item['data']->get_stock_status()) {
$release_attr = $cart_item['data']->get_attribute('pa_release');
$item_name .= " <i style='color:gray;'>" . __('This is a preorder. Shipping after the release', 'woocommerce') . " ( $release_attr )</i>";
}
return $item_name;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mujuonly |
