2018-01-31 17:17
浏览 268


When the user buy a product, I want to save a series of data in custom tables in database. This data will be the product id, custom fields I have, and some other data.

My idea is that this should be done when the payment of the product has been made correctly, that is to say, at the time of payment.

I wanted you to give me advice, I have created a way but I don't know if it is the right one or if you would recommend any other way.

I've edited the thankyou page, and I have inserted this code:

$order = new WC_Order ($order->get_id ();
$check_payment = $order->payment_complete ();

if ($check_payment) {
    global $wpdb;
    wpdb->insert (/* CODE DATABASE*/);

图片转代码服务由CSDN问答提供 功能建议

当用户购买产品时,我想在数据库中的自定义表中保存一系列数据。 这些数据将是产品ID,我拥有的自定义字段以及其他一些数据。</ p>

我的想法是,这应该在产品付款正确时完成,即 说,在付款时。</ p>

我希望你给我建议,我已经创造了一种方法,但我不知道它是否是正确的,或者你是否会建议 任何其他方式。</ p>

我编辑了谢谢你的页面,我已经插入了这段代码:</ p>

  $ order = new WC_Order(  $ order-&gt; get_id(); 
 $ check_payment = $ order-&gt; payment_complete(); 
if($ check_payment){
 global $ wpdb; 
 wpdb-&gt; insert(/ * CODE DATABASE  * /); 
 </ code> </ pre> 
 </ div>

1条回答 默认 最新

相关推荐 更多相似问题