我正在尝试构建一个应用程序,它将我的商业订单,订单商品和数量发给我,
我90%在那里,
function custom_woocommerce_complete_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,它返回所有项目的总和