How to access the custom metadata during the checkout process (PHP)
-
Hi all!
I’d like to show a custom field, “Monthly Price,” for a product. This is just an informational field because the true cart/order/WooCommerce total amount is being showed. The monthly field is not being calculated. I have achieved this using an action, like so:
add_action('woocommerce_cart_totals_before_order_total', 'my_function')
function my_function() { echo <div>Custom cart content here!</div>; }
However, I have one dropdown field configured via Checkout Field Editor, and that can change the monthly price that I want to display.
How can I access the value of the custom field that is being changed? Is this accessible in the WC cart? It looks like it’s a
fee
, however, I can’t access it when I doWC()->getCart()->getFees()
.I know that after the order is submitted, the metadata is held as order metadata. But where is the metadata held before the order is submitted?
I am looking for something like
WC()->getCart()->getFees()['my_custom_checkout_field']
.Thank you!
Kevin.
- The topic ‘How to access the custom metadata during the checkout process (PHP)’ is closed to new replies.