E
E
Elio Don2020-05-08 22:02:11
WordPress
Elio Don, 2020-05-08 22:02:11

How can I display a third price here?

There is a code in the function, there are two prices, how else can I add a third one? Wholesale

add_action( 'woocommerce_single_product_summary', 'art_get_text_field_before_add_card' );
function art_get_text_field_before_add_card() {
global $post, $product;
$text_field     = get_post_meta( $post->ID, '_text_field', true );  
if ( $text_field ) {
    ?>
    <span class="text-field">
        <strong>Мелкий опт: </strong>
        <?php echo $text_field; ?> 
    </span>
<?php }
}
function filter_woocommerce_get_price_html( $price, $_this ) {
    $text_field = get_post_meta( $post->ID, '_text_field', true );
    ob_start();
    if ( $text_field ) {
        ?>
        <span class="text-field">
                <strong>Розница: </strong>
            <?php echo $text_field; ?>
            </span>
        <?php
    }
    $text = ob_get_clean();
    return 'Розница: ' . $price . ' / ' . $text;
}
add_filter( 'woocommerce_get_price_html', 'filter_woocommerce_get_price_html', 10, 2 );


And also how to make it so that, depending on the amount, the price is taken from, say, Small wholesale, for example, if the amount in the basket is more than 30 thousand, then the price of the goods is taken from the Small wholesale item, from 50 thousand, then Wholesale.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question