• Resolved danielmoorehbd

    (@danielmoorehbd)


    Hi,

    We have an issue where we have variable products, all of which are on sale, but the Sale sticker doesn not show on some variations, it is most odd.

    We haven’t modified default behaviour of the Sale sticker, so am unsure as to what the casue is.

    Many Thanks in advance for the assistance.

    Kind Regards

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support EtienneP a11n

    (@etiennep)

    Thanks for the link to a product, but it seems the site is not working;


    Link to image: https://cld.wthms.co/iLSTi3

    Either way, have you tested with another theme like Storefront to see if the issue is with the theme?

    If it displays correctly with Storefront, then I would suggest you reach out to the support of your theme to have a look for you.

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    Apologies, that was our fault for something else on the product template! It’s now resolved and the page visible!

    I have devloped a little workaround to this issue, cheating a bit but it works!

    In functions.php add:

    add_action( 'woocommerce_before_single_product_summary', 'product_page_sale_price' );
     
    function product_page_sale_price() {
     
    if ( has_term( 'sale', 'product_tag' ) ) {
    ?>
    <style>
    .SBCSALE {
    z-index: 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999;
    top: 12px;
    left: 12px;
    font-size: 10px;
    background: red;
    border-color: white;
    color: white !important;
    position: absolute;
    border: none;
        border-top-color: currentcolor;
        border-right-color: currentcolor;
        border-bottom-color: currentcolor;
        border-left-color: currentcolor;
    text-align: center;
    color: #fff;
    font-size: 1em;
    font-weight: 700;
    width: 45px;
    height: 45px;
    line-height: 45px;
    border-radius: 45px;
    padding: 0;
    </style>
    <div class="SBCSALE">SALE</div>
    <?php
    } else {
    echo '';
      }
    }

    then give all products where this badge is needed the tag of “sale”.

    This doesn’t “fix” the issue though!

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    Actually, this revision works better, no need to use a product tag, still for functions.php.

    I realised that this wasn’t a “fault” as such, the badge sticks to the featured image (or the first product image) of the product you are viewing, this snip will bypass this and force the sticker to appear on top at all times.

    I’ll leave it here in case anyone else wants to use it:

    add_action( 'woocommerce_before_single_product_summary', 'product_page_sale_price' );
     
    function product_page_sale_price() {
    global $product;
    
    if ( $product->is_on_sale() ) {
    ?>
    <style>
    .NEWSALEBADGE {
    z-index: 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999;
    top: 12px;
    left: 12px;
    font-size: 10px;
    background: red;
    border-color: white;
    color: white !important;
    position: absolute;
    border: none;
        border-top-color: currentcolor;
        border-right-color: currentcolor;
        border-bottom-color: currentcolor;
        border-left-color: currentcolor;
    text-align: center;
    color: #fff;
    font-size: 1em;
    font-weight: 700;
    width: 45px;
    height: 45px;
    line-height: 45px;
    border-radius: 45px;
    padding: 0; }
    .onsale {
    	display: none;
    }
    </style>
    <div class="NEWSALEBADGE">SALE</div>
    <?php
    } else {
    echo '';
      }
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WooCommerce “Sale!” sticker has disappeared!’ is closed to new replies.