A Wordpress theme i'm using has a custom added to cart popup message from the default one when a product is added to the cart, however, it only seems to work on the product archive pages and not the single product pages. When I add an item to the cart on a single product page, the notification comes up and shows the product image in the message, but not the product name. This happens for both variable and simple products on the single product page. (See screenshot below)
This is the code that is used to show the popup notification:
public function added_to_cart_template() {
$text = esc_html__( 'has been added to your cart', 'mixmart' );
echo <<<HTML
<script type="text/html" id="tmpl-added-to-cart-template">
<div class="notification-added-to-cart">
<div class="notification-wrap">
<div class="ns-thumb d-inline-block"><img src="{{{data.src}}}" alt="{{{data.name}}}"></div>
<div class="ns-content d-inline-block"><p><strong>{{{data.name}}}</strong> $text </p></div>
</div>
</div>
</script>
HTML;
}
Maybe it might just be easier to change the message to "Product successfully added to cart!" but it would be nice to show the product name. I can't figure out why it works everywhere but the single product pages however..
question from:
https://stackoverflow.com/questions/65838057/custom-added-to-cart-message-doesnt-show-product-name-on-single-product-pages 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…