dtwxmn8741 2019-07-30 14:15
浏览 56

没有现有订单的产品“已售出”的woocommerce挂钩

I am trying to find a hook for Woocommerce wherein I can "ping" the woocommerce system that a unit/s of a particular product was "sold" without having to create the order inside woocommerce.

I have an external service which "reduces" stock (in woocommerce) without recording the order in woocommerce.

I want to append an additional code to this function so that some of the other functions can be "triggered".

I have tried using :

$new_quantity = wc_update_product_stock( $product, $quantity_purchased, 'decrease');
$new_quantity = wc_update_product_stock( $product, $newstock);

$newstock is updated quantity and $quantity_purchased is unit sold. I tried "reducing" stock using native woocommerce hook and then resetting it back to the actual quantity.

It did work (as it is meant to be) but did not fire the other functions.

I want to trigger all the functions that are supposed to trigger when a product sells. For example, the total_sales Custom Field, which is native woocommerce custom field to increase/decrease per the sale quantity (which doesn't happen currently).

ALL THIS without having to create the Woocommerce order.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?