Virtuemart 重复订单

发布于 2024-10-25 22:38:05 字数 1805 浏览 3 评论 0原文

问题是我想在我的网站上实现以下功能: 在帐户设置 - 订单详细信息中,我想添加一个按钮,将该订单中的所有产品添加到购物车。 现在,我几乎了解了如何在飞行页面和浏览页面上实现添加到购物车功能。我真的不明白应该如何将多个商品传递到订单详细信息页面上的“添加到购物车”功能,以及如果商品缺货或未发布,ps_cart 将如何处理它。 这是浏览页面中添加到购物车表单的代码:

<form action="<?php echo $mm_action_url ?>index.php" method="post" name="addtocart" id="addtocart<?php echo $i ?>" class="addtocart_form" <?php if( $this->get_cfg( 'useAjaxCartActions', 1 ) && !$notify ) { echo 'onsubmit="handleAddToCart( this.id );return false;"'; } ?>>
    <?php echo $ps_product_attribute->show_quantity_box($product_id,$product_id); ?><br />
    <input type="submit" class="<?php echo $button_cls ?>" value="<?php echo $button_lbl    ?>" title="<?php echo $button_lbl ?>" />
    <input type="hidden" name="category_id" value="<?php echo  @$_REQUEST['category_id'] ?>" />
    <input type="hidden" name="product_id" value="<?php echo $product_id ?>" />
    <input type="hidden" name="prod_id[]" value="<?php echo $product_id ?>" />
    <input type="hidden" name="page" value="shop.cart" />
    <input type="hidden" name="func" value="cartadd" />
    <input type="hidden" name="Itemid" value="<?php echo $sess->getShopItemid() ?>" />
    <input type="hidden" name="option" value="com_virtuemart" />
    <input type="hidden" name="set_price[]" value="" />
    <input type="hidden" name="adjust_price[]" value="" />
    <input type="hidden" name="master_product[]" value="" />
</form>

我想知道是否需要将所有这些传递给 ps_cart? 我不期望你们中的任何人都能提供完全准备好的扩展,如果您能为我指明正确的方向,那就太好了。 谢谢!

编辑: 我能够设置“添加到购物车”按钮,现在我必须传递所需的数据。 如果它能与至少一项一起工作,那就太好了,然后我就会开始考虑如何更改代码。

编辑2: 我能够使其在一款产品上完美运行。但是如何将多个产品 ID 及其数量传递给添加到购物车功能呢?

The thing is that I would like to implement the following functionality to my site:
In the account settings - order details I would like to add a button that would add all the products from that very order to cart.
Now, I pretty much get it how the add to cart functionality is implemented on the flypage and browse page. I can't really get how should I pass multiple items to the add to cart function on order details page and how it'll be processed by ps_cart if an item is out of stock or is unpublished.
Here's the code of the add to cart form from browse page:

<form action="<?php echo $mm_action_url ?>index.php" method="post" name="addtocart" id="addtocart<?php echo $i ?>" class="addtocart_form" <?php if( $this->get_cfg( 'useAjaxCartActions', 1 ) && !$notify ) { echo 'onsubmit="handleAddToCart( this.id );return false;"'; } ?>>
    <?php echo $ps_product_attribute->show_quantity_box($product_id,$product_id); ?><br />
    <input type="submit" class="<?php echo $button_cls ?>" value="<?php echo $button_lbl    ?>" title="<?php echo $button_lbl ?>" />
    <input type="hidden" name="category_id" value="<?php echo  @$_REQUEST['category_id'] ?>" />
    <input type="hidden" name="product_id" value="<?php echo $product_id ?>" />
    <input type="hidden" name="prod_id[]" value="<?php echo $product_id ?>" />
    <input type="hidden" name="page" value="shop.cart" />
    <input type="hidden" name="func" value="cartadd" />
    <input type="hidden" name="Itemid" value="<?php echo $sess->getShopItemid() ?>" />
    <input type="hidden" name="option" value="com_virtuemart" />
    <input type="hidden" name="set_price[]" value="" />
    <input type="hidden" name="adjust_price[]" value="" />
    <input type="hidden" name="master_product[]" value="" />
</form>

I wonder if I'd need to pass all of these to ps_cart?
I don't expect from any of you a completely ready extension, it would be great if you could point me in the right direction.
Thanks!

EDIT:
I was able to set up the add to cart button, now I have to pass the needed data.
It would be great if it would work with at least one item, then I'd start thinking how to alter the code.

EDIT 2:
I was able to make it work flawlessly for one product. But how can I pass multiple Product Id's and their quantities to the add to cart function?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不爱素颜 2024-11-01 22:38:05

ps_cart 中的当前代码已经有一个循环来迭代发送到购物车的多个产品 ID。从那里的代码来看,我会简单地将您想要添加到购物车的所有产品 ID 放入 prod_id 数组中。您会注意到 prod_id、set_price、adjust_price 和 master_product 都是表单中的数组。我的猜测是,您需要为要添加的每个产品输入这些值,ps_cart 将完成其余的工作。

The current code in ps_cart already has a loop to iterate through multiple product IDs that are sent to the cart. From the look of the code there, I would simple put all of the product IDs you want to add to the cart in to prod_id array. You will notice that prod_id, set_price, adjust_price, and master_product are all arrays in the form. My guess is that you will need to put in those values for each product you want to add and ps_cart will do the rest.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文