Problem:
The customer reports that the "Added to Cart" message is not displaying correctly on their product page, even though a previous similar issue had been resolved. The initial troubleshooting step of toggling the AJAX add to cart buttons did not resolve the issue.
Solution:
I identified that the issue was caused by a specific line of code in the template that interfered with the wpv-add-to-cart-message shortcode:
[wpv-conditional if="( '[wpv-post-body]' eq '0' )" evaluate="false"]<h2>Description</h2>[/wpv-conditional]
To fix, I went ahead and changed the conditional to use a custom function:
The line in the template was changed to:
<div class="col-sm-8">[wpv-conditional debug="false" if="( wpv_conditional_post_has_content() eq '0' )"]<h2>Description</h2>[/wpv-conditional] </div>
I added the following check function to the theme's functions.php file:
function wpv_conditional_post_has_content($type, $object) {
$return = 0;
if ( $type == 'products' ) {
if ( empty( $object->post_content ) ) {
$return = 0;
} else {
$return = count($object->post_content);
}
}
return $return;
}
After that I tested it and the 'Description' title is being displayed correctly and so is the added to cart message.