使用自定义网关API付款后,WooCommerce空购物车 [英] WooCommerce Empty cart after payment with custom gateway API

查看:104
本文介绍了使用自定义网关API付款后,WooCommerce空购物车的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发用于woocommerce的Merchant Safe Unipay(MSU)的自定义API,并且需要在成功付款后更改数量.

I'm working on custom API for Merchant Safe Unipay (MSU) for woocommerce and need to change quantity after successful payment.

这是过程:

  1. 客户在购物袋中收集物品
  2. 单击全部付款"后,它会重定向到需要填写信用卡信息的MSU
  3. 付款后,MSU将他送回网站,PHP在该网站上发送电子邮件并打印有关付款的消息.

一切正常,但无法找到在何处以及如何在已付款的购物卡中标记所有产品并更改数量的标记.

All works well but can't find hook where and how to mark all products from shopping card payed and change quantity.

我该怎么做?

谢谢

推荐答案

通常在付款过程之后,客户将被重定向到谢谢"页面(或已收到订单",客户可以在其中查看其已付款的订单)……通常是购物车在某处清空(我不记得确切在哪里).

Normally after payment process, the customer is redirected to "Thank you" page (or "Order received" where customer can review his payed order)… Normally the cart is emptied somewhere (I don't remember where exactly).

因此,如果未清空,则需要使用(2个不同的钩子选项):

So if not emptied, you need to do it for example with (2 different hooks options):

add_action( 'woocommerce_checkout_order_processed', 'order_received_empty_cart_action', 10, 1 );
// or 
// add_action( 'woocommerce_thankyou', 'order_received_empty_cart_action', 10, 1 );
function order_received_empty_cart_action( $order_id ){
    WC()->cart->empty_cart();
}

该代码会出现在您活动的子主题(或主题)的function.php文件中,或者出现在任何插件文件中.

The Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

您将不得不对其进行测试,以查看是否方便……

You will have to test that, to see if it's convenient…

这篇关于使用自定义网关API付款后,WooCommerce空购物车的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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