• Resolved teachermark

    (@teachermark)


    Dear all,

    I am using a piece of code for the simple products zo people can see the price when they change the amount of products on that product page.

    The piece of code is working good, but the problem is the following. When people are adding a product above an amount of numbers the will get a discount. So for instance:

    Product 1 = 0,95,- cents but when order this product not one but in an amount of 100 (or more) the will get a discount of 5 cents (so 0,90,- cents for the product). This is visible on the checkout page, but it’s not visible on the simple page of the product itself.

    Who can help me out? Kind regards Mark

    See the code:

    
    add_action( 'woocommerce_single_product_summary', 'woocommerce_total_product_price', 31 );
    function woocommerce_total_product_price() {
        global $woocommerce, $product;
        // let's setup our divs
        echo sprintf('<div id="product_total_price" style="margin-bottom:20px;">%s %s</div>',__('Product totaal:','woocommerce'),'<span class="price">'.$product->get_price().'</span>');
        ?>
            <script>
                jQuery(function($){
                    var price = <?php echo $product->get_price(); ?>,
                        currency = '<?php echo get_woocommerce_currency_symbol(); ?>';
    
                    $('[name=quantity]').change(function(){
                        if (!(this.value < 1)) {
    
                            var product_total = parseFloat(price * this.value);
    
                            $('#product_total_price .price').html( currency + product_total.toFixed(2));
    
                        }
                    });
                });
            </script>
        <?php
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @teachermark ,

    I can suggest one of the free plugins that do the same and more on this topic. It can help you set a bulk discount based on the amount also shows the price on a single product page before/after the discount. Check it out here – Discount Rules for WooCommerce

    The mentioned code is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    If you need a paid solution, you can consider taking help from one of our partner’s website.

    Thank you ??

    Hi there,

    We’ve not heard back from you in a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Thank you ??

    Thread Starter teachermark

    (@teachermark)

    Hi Rashed,

    Not sure, we have multiple bulk discounts per product the price on discount differs. So we should all that reenter in this plugin for it to work? Or can this plugin read the bulk discounts that already on this product for it to work?

    Thread Starter teachermark

    (@teachermark)

    This is the code from the discount, can we combine this? I am not that code in codes if you my notice haha. Sorry guys, hoping you can help me out with this.

    			$new_css = esc_attr( get_option( 'woocommerce_t4m_css_new_price', 'color: #4AB915; font-weight: bold;' ) );
    			$bulk_info = sprintf( __( 'Incl. %s discount', 'wc_bulk_discount' ), ( $discount_type == 'flat' || $discount_type == 'fixed' ? get_woocommerce_currency_symbol() . $coeff : ( round( ( 1 - $coeff ) * 100, 2 ) . "%" ) ) );
    
    			return "<span class='discount-info' title='$bulk_info'>" .
    			"<span>$price</span>" .
    			"<span class='new-price' style='$new_css'> ($bulk_info)</span></span>";
    • This reply was modified 3 years, 9 months ago by teachermark.
    • This reply was modified 3 years, 9 months ago by teachermark.
    Plugin Support Damianne P (a11n)

    (@drwpcom)

    Hi @teachermark. As Rashed advised, the best option for coding questions like this are through the Facebook group or the WooCommerce Community Slack. I hope that you will be able to find some assistance in one of those two places.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Show discount on simple product page’ is closed to new replies.