更改发送到产品说明的付款网关数据

时间:2019-10-06 16:34:05

标签: php wordpress woocommerce payment-gateway

我有一个用于woocommerce的支付网关,但是在支付网关仪表板中产品的产品名称中,正好收到以下代码中的产品名称。

产品名称:Apple AirPods 说明:用于bla bla的无线设备

我收到的是:Apple AirPods

我想要的东西:要在产品名称旁边显示产品说明,并用w短划线-如下所示;

Apple AirPods-过去经常使用的无线设备

仅发送产品名称并在此正常工作的代码是:

/**
     * Process the payment and return the result.
     * @param  int $order_id
     * @return array
     */
    public function process_payment($order_id) {
        $order = wc_get_order($order_id);
        $order_items = array();
        //get order items date(DateTime::ISO8601)
        $time_stamp = time() + $this->payment_expiry * 60 * 60;
        foreach ($order->get_items() as $item) {
            $product = $item->get_product();
            $item_data ['itemId'] = $product->get_sku() ? $product->get_sku() : $item->get_product_id();
            $item_data ['description'] = $product->get_name();
            $item_data ['quantity'] = $item->get_quantity();
            $item_data ['price'] = wc_format_decimal($product->get_price(), 2);
            $order_items[] = $item_data;
        }
        //send request to fawry to create charge
        $chargeRequest = array(
            'merchantRefNum' => $order_id,
            'merchantCode' => $this->merchant_code,
            'customerProfileId' => $order->get_customer_id(),
            'customerMobile' => $order->get_billing_phone(),
            'customerEmail' => $order->get_billing_email(),
            'paymentMethod' => "PAYATFAWRY",
            'amount' => WC()->cart->total,
            'currencyCode' => $order->get_currency(),
            "description" => $this->description,
            'chargeItems' => $order_items,
            'paymentExpiry' => date('c', $time_stamp),
            'signature' => hash('sha256', $this->merchant_code . $order_id . $order->get_customer_id() . 'PAYATFAWRY' . WC()->cart->total . $this->secure_key),
        );

1 个答案:

答案 0 :(得分:1)

更改此行,它应该会产生预期的效果。

$item_data ['description'] = $product->get_name();

对此

$item_data ['description'] = $product->get_name() . " - " . $product->get_description();