Forum Replies Created

Viewing 15 replies - 1 through 15 (of 30 total)
  • Thread Starter danielmoorehbd

    (@danielmoorehbd)

    Hi @imazed,

    Yes it does.

    To get around the issue, I’ve added this into /theme-folder/woocommerce/loop/sale-flash.php:

        if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
        global $post, $product;
        if ( ! $product->is_in_stock() ) return;
        $sale_price = get_post_meta( $product->id, '_price', true);
        $regular_price = get_post_meta( $product->id, '_regular_price', true);
        if (empty($regular_price)){ //then this is a variable product
    //LINE BELOW CAUSING FATAL ERROR ON SEARCH PAGES
            $available_variations = $product->get_available_variations();
            $variation_id=$available_variations[0]['variation_id'];
            $variation= new WC_Product_Variation( $variation_id );
            $regular_price = $variation ->regular_price;
            $sale_price = $variation ->sale_price;
        }
        $sale = ceil(( ($regular_price - $sale_price) / $regular_price ) * 100);
    ?>
    <?php if ( !empty( $regular_price ) && !empty( $sale_price ) && $regular_price > $sale_price ) : ?>
        <?php echo
            apply_filters( 'woocommerce_sale_flash', '<span class="onsale">-' . $sale . '%</span>', $post, $product );
        ?>
    <?php endif;

    Not the best methord in the world… in fact, it triggers a notice about calling up Woo functions directly! A quick solution was needed…

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    @wprock That’s a Simple product.

    On the category page, it no longer displays the Sale badge on Variable products, last night, all products on the category page I linked above had a badge, this morning, only the simple products do. Odd as nothing was changed to trigger this.

    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 '';
      }
    }
    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)

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    This issue seemed to go away on it’s own…

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    I fixed the issue!

    I found that using the Hide My WordPress Plugin, this fiddles with the path on the front end…

    Solution was adding:
    RewriteCond %{REQUEST_URI} my-contents/(.*)$
    into htaccess, so it looks like this as a whole:

    # BEGIN AAM Media Access Control
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} -f
        RewriteCond %{REQUEST_URI} \.(pdf|doc|docx|ppt|pptx|pps|ppsx|odt|xls|xlsx|psd)$
        RewriteCond %{REQUEST_URI} wp-content/uploads/(.*)$
        RewriteCond %{REQUEST_URI} my-contents/(.*)$
        RewriteRule . /index.php?aam-media=1 [L]
    </IfModule>
    # END AAM Media Access Control

    New here? Read this: https://aamplugin.com/article/how-to-manage-access-to-the-wordpress-media-library

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    Hi @jricketts4,

    This is the spooky bit, it does work! It just generates an error once a day, but not always at the same time each day…

    The full message is below, I’ve asked their plugin support page, but this wasn’t how the error started, it started crying about this particular line in the Storefront theme, I’ve commented it out and the error is now picking on a plugin:

    Error Details
    =============
    An error of type E_ERROR was caused in line 48 of the file /wp-content/plugins/side-cart-woocommerce/public/class-xoo-wsc-cart-data.php. Error message: Uncaught Error: Call to a member function get_cart() on null in /wp-content/plugins/side-cart-woocommerce/public/class-xoo-wsc-cart-data.php:48
    Stack trace:
    #0 /wp-includes/class-wp-hook.php(286): xoo_wsc_Cart_Data->get_cart_content('')
    #1 /wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)
    #2 /wp-includes/plugin.php(465): WP_Hook->do_action(Array)
    #3 /wp-content/plugins/side-cart-woocommerce/public/partials/xoo-wsc-markup.php(68): do_action('xoo_wsc_cart_co...')
    #4 /wp-content/plugins/side-cart-woocommerce/public/class-xoo-wsc-cart-data.php(37): require_once('/var/www/vhosts...')
    #5 /wp-includes/class-wp-hook.php(286): xoo_wsc_Cart_Data->get_cart_markup('')
    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    Hi @3sonsdevelopment,

    I’ve manged to do this!
    I’ll detail my steps for any reader that wishes to follow:
    1) Make a new template file, I’ve created one called template-ouringredients.php
    2) Create a new page in WordPress, set this page template in page attributes
    (Find out how to create a template PHP file here >> https://www.cloudways.com/blog/creating-custom-page-template-in-wordpress/)
    3) Use this code:

    get_header(); ?>
    
    <center><h2 class="entry-title"><?php the_title(); ?></h2></center>
    
    	<div id="primary" class="content-area">
    		<main id="main" class="site-main" role="main">
    
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    			
    			<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>			
    			     
    			    
    			     <div class="entry">
    
    			       <?php the_content(); ?>
    
    			     </div>
    
    			     
    			 </div>
    
    			 <?php endwhile;?>
    
    			 <?php endif; ?>
    <?php
    
    $terms = get_terms("pa_our-ingredients");
    
    foreach ( $terms as $term ) {
    $image_id = get_term_meta( $term->term_id, 'image', true );
    $image_data = wp_get_attachment_image_src( $image_id, 'thumbnail' );
    echo '<div class="ingredient">';
    echo '<a href="'.get_term_link($term->slug, $term->taxonomy).'">';
    echo '<img src="' . esc_url( $image_data[0] ) . '">';
    echo "<caption>" . $term->name . "</caption>";
    echo '</a>';
    echo '</div>';
    }
    
    ?>
    
    		</main><!-- #main -->
    	</div><!-- #primary -->
    
    <style>
    div.ingredient {
    	width: 150px;
    	height: 300px;
    	float: left;
    	margin-left: 5px;
    	margin-right: 5px;
    	text-align: center;
    }
    </style>
    
    <?php
    get_footer();

    That’s it! I hope this helps someone ??

    • This reply was modified 5 years, 2 months ago by danielmoorehbd. Reason: Mark as resolved
    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    And is if by magic, everything is working perfectly today… as if it never went wrong? …

    I’ll close this for now and come back if it returns…

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    Hi @3sonsdevelopment,

    Sorry about that, try this and see if it helps: https://www.sbcgels.com/static/sale_price_issue_august_2019.html

    Also, this is our first time using this feature.

    Kind Regards

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    Hi @mailmechanic,

    The email log is via the Mail Log plugin in WordPress, what is actually sent is what we see on the log, interesting that I never see any attempts, which tells me it isn’t being attempted after the API call.

    I’ve manually updated the stock levels in wp-admin but that doesn’t work either so we have one of 2 scenarios here,
    1) It only emails out when an order is placed
    or
    2) The SMTP change is the sole reason to trigger, we just got lucky with timing!

    What I can’t understand is this, this was working perfectly fine until a few weeks ago, but no work, plugin installs, or updates were made around the time it stopped… I’m beginning to wonder if there is something to address in CRON?

    I’m open to any suggestions of what to do next!

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    Some notes today:
    – Searching through the wp-contents folder for the hook woocommerce_email_recipient_low_stock only turned up the 1 result in the WooCommerce plugin itself, otherwise, nothing else there.

    – I have updated WooCommerce to the latest version just now so hopefully this will resolve the issue! I’ll leave it overnight to brew.

    Would it make any difference the fact that the majority of our stock updates, including depletion, are happening over an API? (So a prodct can hit low/out of stock without web purchase, technically). – Note this has never caused an issue before…

    Kind Regards

    Thread Starter danielmoorehbd

    (@danielmoorehbd)

    Thanks @mailmechanic,

    I’ll give that a try and look at the results in the morning!

    This is odd though, I changed the SMTP settings yesterday to something else before changing it back and 1 of these emails did make it through, but it has stopped again now we’ve let it settle… – just to add to the complexity!

    Kind Regards

Viewing 15 replies - 1 through 15 (of 30 total)