samedi 25 avril 2015

Adjust price if addons are set


Hi i have woocommerce addons plugin in my wordpress shop, for users to choose a weight and calculate the price upon the weight, i have this code that adds the main price to the price of KG, For example the cake costs 100$ per kg

in Cart it shows 700$ for 6 KG's. but it must show 600. So it adds the main price after the calculation.

here is the code

public function add_cart_item( $cart_item ) {
    // Adjust price if addons are set
    if ( ! empty( $cart_item['addons'] ) && apply_filters( 'woocommerce_product_addons_adjust_price', true, $cart_item ) ) {



        foreach ( $cart_item['addons'] as $addon ) {
            if ( $addon['price']  ) {

            }
        }

        $cart_item['data']->adjust_price($addon['price'] );
    }

    return $cart_item;
}


Aucun commentaire:

Enregistrer un commentaire