I am using WooCommerce plugin and have the following query:
Within the single product page, I have a product where based on certain selections by the buyer, a shipping cost value is calculated, which I then need to pass/include as part of the cart items as a new column, "Shipping Cost" when viewing your cart.
The thing is though, the buyer might decide to buy say three different products where each of these three products might have varied shipping cost calculations, after pressing the "Add to Cart" button three times.
For example:
Product A selections calculates a Shipping Cost of $2.00
Product B selections calculates a Shipping Cost of $4.00
Product C selections calculates a Shipping Cost of $6.00
So based on the above, when the buyer has finished shopping and presses "View Cart", I want them to see:
Item Price Shipping Cost Quantity Total
---------------------------------------------------------------------------------------
Product A $10 $2 1 $10
Product B $5 $4 1 $5
Product C $15 $6 1 $15
It is the "Shipping Cost" custom field column I would like to add to the cart, which is what I am unsure how to do.
Further to the above, I also want to add to the "Cart Totals" below, another custom field of "Shipping Cost" which would total $12, which would then beed added to overall Product Total, i.e.
Cart Totals
Cart Subtotal $30
Shipping Cost $12
Order Total $42
Some of the code that I have used for the Cart Total shipping cost is:
function woo_add_cart_fee() {
global $woocommerce;
$woocommerce->cart->add_fee( __('Shipping Cost', 'woocommerce'), 100 );
}
add_action( 'woocommerce_before_calculate_totals', 'woo_add_cart_fee');
So, I need to know how to add the "Shipping Cost" to both the Cart Product Details as well as to the Cart Totals.
Any coding help would be much appreciated.
Thanks.