Ham*_*ian 2 php wordpress woocommerce woothemes
我正试图获得'订单价格'和其他细节.
但$order->get_order_total没有任何返回,也没有出现错误.
如何获得订单元和细节?
add_action( 'woocommerce_thankyou', function($order_id){
global $wpdb;
global $woocommerce;
$order = new WC_Order($order_id);
if ( $order->status != 'failed' ) {
$wpdb->show_errors = TRUE;
$wpdb->suppress_errors = FALSE;
$table_name = $wpdb->prefix . "Arvand_Marketing";
$amount = $order->get_order_total;
$user_market = get_post_meta( $order->id, 'extra-field', true );
$wpdb->insert( $table_name, array( 'email' => '$user_market', 'amount'=>'$amount') );
if ($wpdb->last_error) {
die('error=' . var_dump($wpdb->last_query) . ',' . var_dump($wpdb->error));
}
}
});
Run Code Online (Sandbox Code Playgroud)
get_order_total()不是一件事.您需要使用get_formatted_order_total()方法或get_total()方法.
// Get the formatted order total
$order->get_formatted_order_total();
// Get the stored order total (makes use of $order->order_total)
$order->get_total();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8612 次 |
| 最近记录: |