MarketPress default "Buy now" button not working with Twenty Thirteen Child Theme

The “Buy now” button of my product pages is not adding any item to the cart after clicking it. It reloads the page and returns the message:

“There are no items in your cart - go add some !”

During the chat we ran a plugin/theme conflict test and found that the issue was not there if using a default theme like Twenty Seventeen, but it is if using the current theme, which is a child theme of Twenty Thirteen theme. I wonder what happened with the theme.. it has worked for years :slight_frown:

  • Katya Tsihotska
    • Support & QA

    Hi Kris Donley

    Hope you're having a wonderful day!

    I've had a closer look at your child theme and find out that the issue is related to the mp_product.php template in your child theme. If we'll rename or remove the template (so the MarketPress will use the default template) everything works fine. I've reviewed the code of this template but wasn't able to find the cause of the issue.

    Since this is dealing with more advanced coding topics, I'm going to ping our SLS Team (code experts) to get their valuable feedback on this issue. One of our SLS members will reply back here as soon as more information is available.

    Please keep in mind that our SLS Team deals with more complicated issues, thus it may take a little longer for them to reply here. Thank you for your patience while we look into this further.

    Kind regards,
    Katya

  • Kris Donley
    • New Recruit

    Very good information! I don't think there should be anything too custom in that template so if recommended I just change to default that SHOULD be fine :slight_smile:

    Let me know and I'll leave it alone until we hear the final verdict from SLS.

    Thank-you!

  • Katya Tsihotska
    • Support & QA

    Hi Kris Donley

    If you'd like to find out the cause of the issue, it's better to leave that file. As a temporary solution, you can rename it (ex. _mp_product.php), so MarketPress will use the default template but our code experts will still be able to check the template file with the issue.

    However, if you don't care about the cause, you can just remove the file (but I still recomend you to store a backup copy of the file just in case).

    But please, let us know about your decision :slight_smile:

    Kind regards,
    Katya

  • Panos
    • SLS

    Hi Kris Donley ,

    You need to wrap the product content in a class mp-single-product and instead of
    mp_buy_button(true, 'single');
    you can use:

    $product = new MP_Product( get_the_ID() );
    $product->buy_button( true, 'single' );

    I have already done those changes on your mp_product.php file and seems that products are added to cart. Could you confirm on your side too?

    Thanks!

  • Kris Donley
    • New Recruit

    Yes, seems like everything is back to normal!! TYTY

    Any idea what would have caused this to occur?

    We have never customized that file besides maybe by changing the preferential options that are available through the GUI in Wordpress. The issue seemed to co-inside with the Wordpress update last month.

  • Katya Tsihotska
    • Support & QA

    Hi Kris Donley

    This issue is rather related to the MarketPress, as the mp_buy_button(); function is deprecated. Since the MarketPress 3.0, the plugin structure was changed a bit and became more object-oriented (meant based on classes and objects than on separate functions). So for better compatibility with current and especially with future versions, it's recommended to use the new function, based on the MP_Product class, as my colleague Panos described above.

    Hope this clarifies a bit :slight_smile:

    Kind regards,
    Katya

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.