【问题标题】:How to get BACS account details in Woocommerce using API?如何使用 API 在 Woocommerce 中获取 BACS 帐户详细信息?
【发布时间】:2019-10-15 10:49:35
【问题描述】:

我已经完成了用 PHP 创建的https://acp.sample.ph/wc/v3/order,但是 API 的响应没有显示银行账户转账 (BACS) 的银行/账户详细信息。我正在使用包 automattic/woocommerce 来获取 API。我获取的这个 API 来自 WordPress woocommerce。下面是我的示例代码。

    $woocommerce = new Client(
        'https://acp.sample.ph', 
        $credential['key'], 
        $credential['secrete'],
        [
            'wp_api' => true, 
            'version' => 'wc/v3',
            'query_string_auth' => true
        ]
    );

    $data = array(
        "order_id"=>"717",
        "payment_method"=>"bacs"
    );

    $accounts = $woocommerce->post('process_payment', $data);

    echo '<pre>';
    print_r($accounts);
    echo '</pre>';

【问题讨论】:

    标签: php wordpress api woocommerce


    【解决方案1】:

    您可能需要创建自己的端点或更改 Order API 响应

    你能试试这个吗---

    function prefix_wc_rest_prepare_order_object( $response, $object, $request ) {
        // Get the value
        $bacs_info = get_option( 'woocommerce_bacs_accounts');
    
        $response->data['bacs_info'] = $bacs_info;
    
        return $response;
    }
    add_filter( 'woocommerce_rest_prepare_shop_order_object', 'prefix_wc_rest_prepare_order_object', 10, 3 );
    

    【讨论】:

      猜你喜欢
      • 2019-05-08
      • 2016-11-06
      • 1970-01-01
      • 2020-02-04
      • 2021-04-25
      • 1970-01-01
      • 1970-01-01
      • 2020-07-11
      • 1970-01-01
      相关资源
      最近更新 更多