Skip Navigation

[Resolved] wpv-add-to-cart-message not diplaying on single product

This thread is resolved. Here is a description of the problem and solution.

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.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 6 replies, has 2 voices.

Last updated by Mateus Getulio 5 months, 2 weeks ago.

Assisted by: Mateus Getulio.

Author
Posts
#2706547

Hi,

Seems it's an old issue which was resolved, but it's still doesn't work on my site.

See this product for example: hidden link

Thx

#2706675

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Pierre,

Thanks for contacting us.

Before your ticket is assigned to one of my colleagues, please allow me to walk you through some initial debugging steps. This will help speed up the support process.

Please try to follow these:

- Go to WooCommerce -> Settings -> Products -> Display
- Look for 'Add to cart behavior'
- Uncheck ' Enable AJAX add to cart buttons on archives '

After that please test the cart message again to see if it starts displaying accordingly.

Best,
Mateus

#2706721

Hi Mateus,

Thx for your reply.

The ' Enable AJAX add to cart buttons on archives ' wasn't enable.

I enabled it, with no luck.

I redisabled it, without more luck.

The answer might be else where.

Regards,

Pierre

#2706794

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Pierre,

I would like to request temporary access (wp-admin and FTP) to your site to take better look at the issue. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

I'd also like to ask permission to make a copy/staging version of your site where I can debug this closely without affecting the live site.

I'll make sure to delete this copy as soon as we get this issue fixed.

I'm afraid of debugging directly on the live site and cause issues to your visitors. Also, it is important to test a different setup as part of the troubleshooting.

Our Debugging Procedures

I will be checking various settings in the backend to see if the issue can be resolved. Although I won't be making changes that affect the live site, it is still good practice to backup the site before providing us access. In the event that we do need to debug the site further, I will duplicate the site and work in a separate, local development environment to avoid affecting the live site.

Privacy and Security Policy

We have strict policies regarding privacy and access to your information. Please see:
https://toolset.com/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

**IMPORTANT**

- Please make a backup of site files and database before providing us access.
- If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this: hidden link

Please, let me know if you need any additional details. Have a nice day.

#2707059

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Pierre,

Thank you for sharing that information. I debugged this but so far I couldn't find a fix.

I'd like to ask permission to make a copy/staging version of your site where I can continue to debug this closely without affecting the live site. I might need to disable plugins and theme for example.

I'll make sure to delete this copy as soon as we get this issue fixed.

I'm afraid of debugging directly on the live site and cause issues to your visitors. Also, it is important to test a different setup as part of the troubleshooting.

Thank you, please let us know.
Mateus

#2707060

Hi Mateus,

Yes absolutely! Go ahead with duplicating the site!

Many many thx to take the time to work on that.

Regards

#2707269

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Pierre,

I debugged it further and noticed that the following line of code in the template was interfering with the shortcode wpv-add-to-cart-message:

 [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] 

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, can you please test it?

Best,
Mateus

#2707295

Hi, this is perfect!

Amazing job, many thanks!!!