更改发送到产品描述的支付网关数据 [英] Change payment gateway data sent to product description

查看:58
本文介绍了更改发送到产品描述的支付网关数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于 woocommerce 的支付网关,但在支付网关仪表板中产品的产品名称中,产品名称的接收方式与下面的代码相同.

I have a payment gateway for woocommerce, but in the product name of the products in the payment gateway dashboard the product name is received right as the code below.

产品名称:Apple AirPods描述:无线设备用于bla bla

Product name: Apple AirPods Description: Wireless device used to bla bla

我收到了什么:Apple AirPods

What i receive: Apple AirPods

我想要的:想要在产品名称旁边显示带有 w 破折号的产品描述 - 它们之间如下所示;

What i want: want to show the product description next to the product name with w dash - between them as below;

Apple AirPods - 用于 bla bla 的无线设备

Apple AirPods - Wireless device used to bla bla

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

The code that sends the product name only and works fine here is it:

/**
     * 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),
        );

推荐答案

更改此行,我相信它应该会产生预期的效果.

Change this line, and it should give the desired effect I believe.

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

为此

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

这篇关于更改发送到产品描述的支付网关数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆