【发布时间】:2019-08-14 10:14:00
【问题描述】:
我正在设置 WooCommerce 支付插件。我创建了一个付款字段,该字段应在收到付款之前显示订单 ID。
我已经看到这个答案Get the order ID in checkout page before payment process 但是我不知道如何使用自定义函数。
public function payment_fields(){
global $woocommerce;
$amount = floatval( preg_replace( '#[^\d.]#', '', $woocommerce->cart->get_cart_total() ) );
///This works if the order has been already placed
$order = new WC_Order($post->ID);
$order_id = $order->get_id();
$shortcode = $this->shortcode;
$steps="Go to Safaricom Menu on your phone<br>
Select M-PESA<br>
Select Lipa na MPESA<br>
Select Pay Bill<br>
Enter Business No: $shortcode<br>
Enter Account No:$order_id<br>
Enter Amount: $amount <br>
Enter the transaction code you received from MPESA in the form below<br>";
echo wpautop( wptexturize( $steps) );
//This add the form field for Pay bill customers
woocommerce_form_field( 'mpesaid', array(
'title' => __( 'MPESA Reference', 'cwoa-authorizenet-aim' ),
'type' => 'text',
'label' => 'M-PESA Reference',
'required' => true,
'maxlength' => '10'
)
);
}
`
【问题讨论】:
标签: php wordpress woocommerce