脚本宝典收集整理的这篇文章主要介绍了php – WC_Order get_items()及其数量,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我90%在那里,
function custom_woocommerce_@R_360_639@_order_sms( $order_id ) { global $woocommerce; if ( !$order_id ) return; $order = new WC_Order( $order_id ); $PRoduct_list = ''; $order_ITem = $order->get_items(); foreach( $order_item as $product ) { $prodct_name[] = $product['name']; } $product_list = implode( ',\n',$prodct_name ); require "twilio-PHP-master/Services/Twilio.PHP"; $AccountSid = "xxxxxxxxx"; $AuthToken = "xxxxxxxxx"; $client = new Services_Twilio($AccountSid,$AuthToken); $PEople = array( "xxxxxxxxxx" => "Me",); foreach ($people as $number => $name) { $sms = $client->account->messages->sendMessage( "+44xxxxxxxxxx",// the number we are sending to - Any phone number $number,// the sms body "Hey $name,there is a new Order,the order is,$product_list" ); } }
我的问题是我不知道如何获取项目数量,例如我的文字看起来像列表,项目1,项目2,项目3,我想要说项目1 x1,项目2 x2,项目3 x3
我确实尝试挖掘抽象woo commerce文件夹中的电子邮件PHP文件,看看他们如何做,因为他们在电子邮件中发送数量,但有点丢失
同样在类WC_Abstract_Order中我唯一能找到的东西是get_item_total,它返回所有项目的总和
$product['qty'];
$product_details = array(); $order_items = $order->get_items(); foreach( $order_items as $product ) { $product_details[] = $product['name']."x".$product['qty']; } $product_list = implode( ',',$product_details );
以上是脚本宝典为你收集整理的php – WC_Order get_items()及其数量全部内容,希望文章能够帮你解决php – WC_Order get_items()及其数量所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。