반응형
WooCommerce - 주문 ID에서 구독 ID 가져오기
나는 액션 훅에서 그것을 얻으려 하고 있습니다.
그것은 고객이 전환할 때마다 변경되는 것을 나에게 줍니다.
예를 들어,가 인 경우 원본은 입니다.
이제 고객이 만든 모든 스위치는 새로운 주문 ID를 생성하며, 위의 작업을 통해 이 ID를 제공합니다.이 시점에서 나는 , , , 그리고 원본을 가지고 있습니다 ,
어떻게 하면 현재 주문한 것을 받을 수 있습니까?
$subscription ID를 검색하는 전용 기능을 사용할 수 있습니다.
그래서 이게 당신의 코드가 될 수도 있겠군요.
add_action('woocommerce_order_status_changed', 'action_order_status_changed');
function action_order_status_changed( $order_id ){
$subscriptions_ids = wcs_get_subscriptions_for_order( $order_id, array( 'order_type' => 'any' ) );
// We get all related subscriptions for this order
foreach( $subscriptions_ids as $subscription_id => $subscription_obj )
if($subscription_obj->order->id == $order_id) break; // Stop the loop
// The subscription ID: $subscription_id
// The An instance of the Subscription object: $subscription_obj
// ...
}
언급URL : https://stackoverflow.com/questions/43150761/woocommerce-get-the-subscription-id-from-the-order-id
반응형
'programing' 카테고리의 다른 글
wordpress root url을 구하는 방법 (ABSPATH 각 페이지 변경사항) (0) | 2023.11.02 |
---|---|
gprof : 메인 프로그램과 연동되는 공유 라이브러리의 함수에 대한 호출 그래프 생성 방법 (0) | 2023.11.02 |
C에서 지정된 이니셜라이저는 무엇입니까? (0) | 2023.11.02 |
새 줄이 발견될 때까지 차단하면서 stdin에서 줄을 읽는 방법은? (0) | 2023.11.02 |
오래된 도커 컨테이너를 제거하는 방법 (0) | 2023.11.02 |