在向接收到的电子邮件添加订单操作时,payment_method错误调用

时间:2019-02-05 12:08:03

标签: methods woocommerce payment

我正在使用此代码在woocommerce发送的电子邮件接收顺序中显示其他信息。

add_action('woocommerce_email_after_order_table', 'add_order_email_instructions', 10, 2);

function add_order_email_instructions($order, $sent_to_admin) {

if (!$sent_to_admin) {

    if ( isset( $gateways['cod'] ) == $order->payment_method) {
        // cash on delivery method
        do_action('woocommerce_thankyou_lieferung', $order->get_id());
    } else {
        // other methods (ie credit card)

        do_action('woocommerce_thankyou_lieferung', $order->get_id());
    }
  }
}

这给了我错误信息

付款方式调用不正确。订单属性不应直接访问。

在debug.log文件中

我找不到上述代码有什么问题。

1 个答案:

答案 0 :(得分:1)

declare 
  mHalf  Number; 
  l_rec TableA%rowtype; 
  cntr NUMBER := 1; 
  CURSOR cur IS Select * From TableA FOR UPDATE OF columnA; 
begin 

 Select round(count(*)/2,0) Into mHalf From TableA; 

OPEN cur; 
  LOOP 
    FETCH cur INTO l_rec; 
        EXIT WHEN cur%notfound; 
    UPDATE 
      tableA 
    SET 
      columnA=CASE WHEN cntr <= mhalf then 1 else 2 end 
    WHERE 
      CURRENT OF cur; 
    cntr := cntr +1;       
  END LOOP; 

  Commit; 

end;