• Hi
    I am new to woocommerce.
    I set up a few variation products with 2 different weights and prices.
    is there a way for the shopping subtotal to reflect price per lb times the weight set in the variation?
    right now I put 3.99 per lb (I used customer product fields to display PER LB) but the subtotal says 3.99 1 qty or 7.98 2 qty etc…
    can I change that that any product (not all are) that is by weight the subtotal should show 39.90 (3.99 x 10 lbs, qty 1) or 79.80 (3.99 x 10 lbs qty 2) etc..
    and to make it more complicated, can this function work only for products that are by lb and not by case

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter ariban99

    (@ariban99)

    by the way, here is my code to show price per lb ONLY for products that have that tag

    add_filter( ‘woocommerce_get_price_html’, ‘wb_change_product_html’, 10, 2 );
    // Adding a custom field to the price markup
    function wb_change_product_html( $price, $product ) {

    //$wb_price_type = get_field(‘product_price_type’);
    $wb_price_type = get_post_meta( $product->get_id(), ‘product_price_type’, true);

    if($wb_price_type) {
    $price_html = ‘<span class=”amount”>’ . $price . ‘ ‘ . $wb_price_type . ‘</span>’;
    }

    else {
    $price_html = ‘<span class=”amount”>’ . $price . ‘</span>’;
    }

    return $price_html;
    }
    add_filter( ‘woocommerce_cart_item_price’, ‘wb_change_product_price_cart’, 10, 3 );
    // Adding a custom field to the price in the cart
    function wb_change_product_price_cart( $price, $cart_item, $cart_item_key ) {

    //$wb_price_type = get_field( ‘product_price_type’, $cart_item[‘product_id’] );
    $wb_price_type = get_post_meta( $cart_item[‘product_id’], ‘product_price_type’, true );

    if ($wb_price_type) {
    $price = $price . ‘ ‘ . $wb_price_type;
    }
    else {
    $price = $price;
    }
    return $price;
    }
    add_filter( ‘woocommerce_checkout_cart_item_quantity’, ‘wb_checkout_review’, 10, 3 );
    // Adding a custom field to the price in the checkout items
    function wb_checkout_review ( $quantity, $cart_item, $cart_item_key ) {

    //$wb_price_type = get_field( ‘product_price_type’, $cart_item[‘product_id’] );
    $wb_price_type = get_post_meta( $cart_item[‘product_id’], ‘product_price_type’, true);

    if ( $wb_price_type ) {
    $cart_item = ‘ ‘ . $wb_price_type . ” . sprintf( ‘× %s ‘, $cart_item[‘quantity’] );
    }

    else {
    $cart_item = ‘ ‘ . sprintf( ‘× %s’, $cart_item[‘quantity’] ) . ”;
    }
    return $cart_item;

    }

    Hi

    Please share your website’s link

    THANKS

    Thread Starter ariban99

    (@ariban99)

    hi
    its being built, koshernow.com
    you will see 2 sample products under meat>beef menu
    thank you

    Hi

    This site is password protected while under development. Enter your password to access the development site.

    Thread Starter ariban99

    (@ariban99)

    sorry i fixed that, the password protection is removed

    You’re welcome

    You have just one product:

    https://koshernow.com/product/gift-card/

    Thread Starter ariban99

    (@ariban99)

    https://koshernow.com/product/ground-beef/
    i have over 500 products in middle of being built, here is one as an example

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘cart subtotal price x weight variable’ is closed to new replies.