BuddyDev

Search

woocommerce Error

  • Participant
    Level: Initiated
    Posts: 2
    ndungu on #9447

    Hello

    This is one of the best plugins around its really awesome, however, i am getting this error wen i activate it when using woocommerce. The error occurs when viewing the single products under woocommerce.

    Fatal error: Uncaught Error: Call to a member function is_on_sale() on null in /home//public_html/wp-content/plugins/woocommerce/templates/single-product/sale-flash.php:26 Stack trace: #0 /home//public_html/wp-content/plugins/woocommerce/includes/wc-core-functions.php(204): include() #1 /home//public_html/wp-content/plugins/woocommerce/includes/wc-template-functions.php(950): wc_get_template(‘single-product/…’) #2 /home//public_html/wp-includes/class-wp-hook.php(298): woocommerce_show_product_sale_flash(”) #3 /home//public_html/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(”, Array) #4 /home/windowsh/public_html/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #5 /home//public_html/wp-content/plugins/woocommerce/templates/content-single-product.php(48): do_action(‘woocommerce_bef…’) #6 /home//public_html/wp-includes/template.php(690): require(‘/home//…’) #7 /home//public_html/wp-content/plugins/woocommerce/includes/wc-core-f in /home//public_html/wp-content/plugins/woocommerce/templates/single-product/sale-flash.php on line 26

    The code on the php file in woocommerce reads as below

    <?php
    /**
    * Single Product Sale Flash
    *
    * This template can be overridden by copying it to yourtheme/woocommerce/single-product/sale-flash.php.
    *
    * HOWEVER, on occasion WooCommerce will need to update template files and you
    * (the theme developer) will need to copy the new files to your theme to
    * maintain compatibility. We try to do this as little as possible, but it does
    * happen. When this occurs the version of the template file will be bumped and
    * the readme will list any important changes.
    *
    * @see https://docs.woocommerce.com/document/template-structure/
    * @author WooThemes
    * @package WooCommerce/Templates
    * @version 1.6.4
    */

    if ( ! defined( ‘ABSPATH’ ) ) {
    exit; // Exit if accessed directly
    }

    global $post, $product;

    ?>
    <?php if ( $product->is_on_sale() ) : ?>

    <?php echo apply_filters( ‘woocommerce_sale_flash’, ‘<span class=”onsale”>’ . esc_html__( ‘Sale!’, ‘woocommerce’ ) . ‘</span>’, $post, $product ); ?>

    <?php endif;

    /* Omit closing PHP tag at the end of PHP files to avoid “headers already sent” issues. */

    Kindly assist if possible

    Best Regards
    Ndungu

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #9449

    Hi Ndungu,
    Welcome to BuddyDev and my apologies for the inconvenience.

    It seems very strange to me. When you disable MediaPress, does the above code work? Can you please check and confirm.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 2
    ndungu on #9468

    Hello Brajesh Singh,

    Thanks for the response and the welcome.

    Yes! the code works when i disable MediaPress. However, it does not work when i activate MediaPress

    Regards
    Ndungu

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #9505

    Hi Ndungu,
    That is vvery strange. Please allow me to look at one of the sites using MediaPress/WooCommerce and see if I can reproduce it. I will report back.

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #9518

    Hi,
    I tried it now I am sorry but I could not reproduce it. It can see the problem. The product object is not getting initialized and is causing issue.

    Can you please help me in reproducing it. Please let me know the steps to create it on a WordPress, WooCommerce & BuddyPress install.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 2
    ndungu on #9525

    Hello

    Thanks for the response, got the issue

    It was with Firefox > site cookies & cache: solution below

    Cookies; Select Privacy. Under History, select Firefox will Use Custom Settings. Press the button on the right side called Show Cookies. Use the search bar to look for the site. Note; There may be more than one entry. Remove All of them.

    Cache; Select Advanced > Network. Across from Cached Web Content, Press Clear Now.

    just i case

    Best Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #9526

    Thank you.
    Should I consider it as resolved then?

You must be logged in to reply to this topic.

This topic is: not resolved