Search code examples
phpwordpresswoocommercehook-woocommerceorders

What is the WooCommerce hook to for purchases details after checkout?


Does anyone knows what is the hook in WooCommerce to get all the purchase details when you checkout?

I can not find it anywhere.


Solution

  • The hook that you are looking at is woocommerce_checkout_create_order_line_item, located in WC_Checkout method create_order_line_items()

    The woocommerce_checkout_create_order_line_item action hook allows to adjust line item before save. It has 4 defined arguments:

    • $item is the WC_Order_Item_Product object
    • $cart_item_key is the related cart item key
    • $values is the related cart item
    • $order is the WC_Order Object

    All StackOverFlow treads using woocommerce_checkout_create_order_line_item action hook.

    Related: Get Order items and WC_Order_Item_Product in WooCommerce 3