Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Demo of woocommerce_thankyou hook
- // code goes in functions.php for child theme
- add_action ('woocommerce_thankyou', 'myfunction');
- function myfunction($order_id) {
- $order = new WC_Order($order_id);
- $items = $order->get_items();
- foreach ($items as $item) {
- $item_metas = $item['item_meta'];
- $product_ids = $item_metas['_product_id'];
- foreach ($product_ids as $product_id) {
- switch ($product_id) {
- case 1:
- break;
- case 2:
- break;
- default:
- }
- echo '<p>'.$item['name'].' '.$product_id.'</p>';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement