我正在尝试从Thankyou.php订单中读取并将 order_id、sku、价格、数量填充到 javascript 狙击手。我的问题是如何在 php 中“捕获”循环并将这些变量传递给 JavaScript Snipper。
<?php
function CustomReadOrder ( $order_id ) {
// Lets grab the order
$order = wc_get_order( $order_id );
// This is the order total
$order->get_total();
// This is how to grab line items from the order
$line_items = $order->get_items();
// This loops over line items
foreach ( $line_items as $item ) {
// This will be a product
$product = $order->get_product_from_item( $item );
// This is the products SKU
$sku = …Run Code Online (Sandbox Code Playgroud)