We have a bunch of products with either:
- No price
- Zero price
We made them purchasable with the built-in hook but the cart still displays them as having a 0 price
during checkout.
We'd like the cart & checkout summary to display "Special order" or any other text, but it seems WooCommerce invalidates text-based prices.
Tried this :
WooCommerce: Add product to cart with price override?
The above works fine with a number override, but when tried with a text override it defaults back to displaying a 0 price
.
Why? These products are built-to-order and the shop admin will update price after talking to customer/supplier.
Best Answer
You need to filter the strings that display the price and subtotal in the cart. The link you mentioned discussed changing the actual price. In your case the price is $0 until you set an actual price later on. There are probably filters for the cart totals too, but this should be a start:
Of course, this will also apply to any product with a 0 price and maybe not only the ones you have configured to be custom built, so you may need more conditional logic than I've supplied here.
To follow up on your comment....
woocommerce_order_amount_total
is the numerical total and not the displayed html. You can see the functions being called in thecart-totals.php
template.Updated screenshot: