My question is how to sum a fixed price with product subtotal en calculate.
Woocommerce prices are based on quantity but i want the subtotal of a product in cart sum+ with a certain price my code:
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
// $cart_item['data']->set_price($custom_price);
$_product = wc_get_product( $cart_item['data']->get_id() );
$getProductDetail = wc_get_product( $cart_item['product_id'] );
$quantity_cr = $cart_item['quantity'];
$price = get_post_meta($cart_item['product_id'] , '_price', true);
/*Regular Price and Sale Price*/
//echo "Regular Price: ".get_post_meta($cart_item['product_id'] , '_regular_price', true)."<br>";
//echo "Sale Price: ".get_post_meta($cart_item['product_id'] , '_sale_price', true)."<br>";
$opdruk = $cart_item['thwepof_options'];
foreach($opdruk as $cr_item) {
$total_price_each_prduct = $cart_item['line_total'];
$opdruk_value = $cr_item['value'];
//print_r($opdruk_value);
if ($opdruk_value != "Geen opdruk") {
$price_opdruk = $price + 39; // this is the fixed price i want to add (not on quantity based)
}
}
}
3
Answers
Hello you can do this like adding a tax/shipping/etc… in total price
Try this code
You can try use this hook: