0

I need in woocommerce after successful Paypal payment and product status change to complete, to insert some info data about the order product e.g product quantity to one of my custom database tables. what action/filter will do the job any example?

4

1 回答 1

0

经过一些测试,我找到了这个钩子的解决方案

add_action( 'woocommerce_order_status_completed', 'check_quantity' );
function check_quantity($order_id) {

// order object (optional but handy)
$order = new WC_Order( $order_id );

if ( count( $order->get_items() ) > 0 ) {
foreach( $order->get_items() as $item ) {

// for all products if ( $item['id'] > 0 ) {
if ( $item['id'] == 8 ) {
$quantity=$item['qty'];
add_qty($quantity);

   }
  }
 }
}
于 2012-10-14T18:24:36.780 回答