【发布时间】:2014-11-10 12:30:19
【问题描述】:
我之前在这里的某个地方找到了以下脚本,但无法使其正常工作。基本上我想将基本订单详细信息复制到一个新表中(在同一个数据库中),所以我可以从非 wordpress 页面运行一些报告。我已经更改了表名和字段,并将其复制到主题中的 functions.php 中。但它似乎没有做任何事情。任何帮助都会很棒,我真的卡住了。如果这有什么不同,我正在运行 woocommerce 2.2.8。
function add_neworders ($order_id) {
global $woocommerce;
$order = new WC_Order( $order_id );
$total = $order->order_total;
$date = $order->order_date;
global $wpdb;
$table = $wpdb->prefix . 'finacedata';
$wpdb->insert($table, array(
'desctipion' => $name,
'status' => '2',
'date' => $date,
'amount' => $total,
'invoice' => $order_id,
));
add_action( 'woocommerce_new_order', 'add_neworders' );}
【问题讨论】:
标签: php mysql wordpress woocommerce