jacekwilczynski

Untitled

Apr 19th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. add_action('woocommerce_order_status_completed', function (int $orderId) {
  2.     $order = wc_get_order($orderId);
  3.  
  4.     if ($order) {
  5.         foreach ($order->get_items() as $item) {
  6.             $isEvent = $item->meta_exists('_tbsa_eventId');
  7.             if ($isEvent) {
  8.                 $eventPostId = $item->get_meta('_tbsa_eventId');
  9.                 $event       = em_get_event($eventPostId, 'post_id');
  10.                 $location    = $event ? $event->get_location() : null;
  11.                 $town        = $location ? $location->location_town : null;
  12.                 if ($town) {
  13.                     // Teraz $town zawiera nazwę miasta
  14.                 }
  15.             }
  16.         }
  17.     }
  18. }, 10, 1);
Advertisement
Add Comment
Please, Sign In to add comment