• Hi there,

    I use Tiered Price Table for WooCommerce to create discount pricing rules for sale products.

    Unfortunately it seems the following code from line?803 of cartpops-common-functions.php causes a conflict:

    if ( $onsale ) {
    $price .= '<small class="">' . __( 'You save', 'cartpops' ) . ' ' . round( $percentage ) . '%</small>';
    }

    If I have on sale items in the cart I see the following error in the cart :

    Warning: Undefined variable $percentage in /home/comicboo/public_html/wp-content/plugins/cartpops/includes/functions/cartpops-common-functions.php on line 803

    Is there anyway to disable the onsale display or at least hide it?

    I tried to hide it with css, as it shows as ‘You saved 0%’, using this:

    .cpops-cart-item__actions--pricing .cpops-price small {
    display: none !important;
    }

    But the warning still shows on the frontend for anyone who is signed in to their account.

    I’d appreciate any help you can provide asap please!

    • This topic was modified 5 months, 2 weeks ago by JapeNZ.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there,

    You can add a check to ensure that the $percentage variable is defined before attempting to use it. Modify the problematic code to something like this:

    if ( $onsale ) {
    $percentage = isset($percentage) ? $percentage : 0; // Ensure $percentage is defined
    $price .= ‘<small class=””>’ . __( ‘You save’, ‘cartpops’ ) . ‘ ‘ . round( $percentage ) . ‘%</small>’;
    }

    This ensures that $percentage is always set, avoiding the undefined variable warning.

    I hope that helps.

    Best,

    Niel, Cartpops

    Thread Starter JapeNZ

    (@japenz)

    Hi Niel,

    Thank you for the fix!

    Will this be added to the next update, and if so what title will you give the class?
    I just want to confirm if I’ll need to apply the fix again, or update the class in any css I may do after each future update.

    Thanks again!

    • This reply was modified 5 months, 1 week ago by JapeNZ.
    • This reply was modified 5 months, 1 week ago by JapeNZ.

    Hi there,

    This fix won’t be in the next update since it’s a custom setup. You’ll need to keep and update it from time to time.

    Let me know if you need anything else!

    Best,

    Niel, Cartpops

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.