php - 如何从 WooCommerce 订单中获取选定数量的产品?
问题描述
我目前正在开发一个使用 WooCommerce 的 WordPress 项目。我正在尝试制作一个客户可以用来退款订单的表格,而我现在还很遥远。我要解决的一件事是,是否可以让客户选择他们想要退货的精选产品?
下面我使用 WooCommerce 自己的功能来打印所选订单的信息。在这里,我想添加一个可能的输入,让客户选择他们想要退货的商品数量,但我不确定如何退货。
同样用于上下文:这是第二页,它向用户显示他使用此订单订购了哪些商品。在第一页上,客户被询问他们的信息以确保这是他们的订单。在第三页也是最后一页上,用户确定他们想要提出退款请求,以及是否想要发表评论。
$order = wc_get_order( $ordernumber );
foreach ($order->get_items() as $item ) {
$unitprice = $item->get_total() / $item->get_quantity();
echo "<input type='checkbox' name='productinfo[]' value='" .$item->get_name() . "|" . $item->get_quantity() . "|" . $item->get_total() ."'>";
echo '<p>';
echo __('Tuotteen nimi: ' ) . $item->get_name() . '<br>';
if($item->get_quantity() > 1) {
echo "Määrä: " . "<input type='number' name='numberqty' value='" . $item->get_quantity() . "'max='" .$item->get_quantity() . "' min='0' > " . "<br/>";
} else {
echo __('Määrä: ' ) . $item->get_quantity() . '<br>';
}
if ($item->get_quantity() > 1) {
echo __('Tuotteen kappalehinta: ') . $unitprice . '€' . '<br/>';
}
echo __('Tuotteiden kokonaishinta: ' ) . wc_price($item->get_total()) . '</p>' . '<br/>';
}
echo '<p>'. __('Tilauksen yhteishinta: ') . $order->get_total() . '</p>';
如果有人至少可以为我指出正确的方向,我将不胜感激。先感谢您!
解决方案
推荐阅读
- c# - 为什么我在打开然后关闭窗口上的菜单时收到 InvalidCastException?
- python - 在 __init__ raise TypeError("%s() got an unexpected keyword argument '%s'" % (cls.__name__, kwarg))
- augmented-reality - ArSession_update 需要很多时间
- node.js - 意外的令牌o
- intellij-idea - 如何以分离模式从终端运行 Intellij IDEA
- c# - 如何在 IIS 上发布的应用程序中打开列表框中列出的文件(excel、txt、word)?
- python - 如何在 OpenCV 中更改照片的曝光
- eclipse - 期间发生内部错误:“重新加载 maven 项目”
- php - Api Platform 不正确的上下文响应与自定义操作
- javascript - 来自蓝图覆盖样式的 Normalize.css