首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过沙盒2的支付不适用于laravel

通过沙盒2的支付不适用于laravel
EN

Stack Overflow用户
提问于 2018-09-05 19:49:53
回答 1查看 42关注 0票数 0

我的HTML代码中,我试图获得所有值的付款。

代码语言:javascript
复制
<form action='https://sandbox.2checkout.com/checkout/purchase' method='post'>
  <input type='hidden' name='sid' value='901390740' />
  <input type='hidden' name='mode' value='2CO' />
  @foreach(CartProvider::instance()->getCartItems() as $item)
    <input type='hidden' name='li_0_type' value='product' />
    <input type='hidden' name='li_0_product_id' value='{{$item->user_id}}' >
    <input type='hidden' name='li_0_name' value='{{$item->name}}' />
    <input type='hidden' name='li_0_quantity' value='{{$item->quantity}}' >
    <input type='hidden' name='li_0_price' value='{{$item->price}}' />
  @endforeach
  <input type="hidden" name="merchant_order_id" value="Y">
  <input style="margin-left: 675px;margin-top: 75px;" type='submit' name='submit' class="btn btn-success" value='checkout' >
</form>

当我点击结帐按钮时,我将只得到最后一个项目,但我可以通过五个项目。还有它的路线

代码语言:javascript
复制
Route::get('checkout','frontend\CartController@checkout');

和控制器

代码语言:javascript
复制
public function PlaceOrder(){
      $order= new order();
      $order->total_amount=CartProvider::instance()->total;
      $order->user_id='9';
      $order->save();
      $order_id=$order->id;
          foreach (CartProvider::instance()->getCartItems() as $item)
      {


            $order= new orderdetail();
            $order->product_id=$item->id;
            $order->order_id=$order_id;
            $order->price=$item->price;
            $order->subtotal=$item->price*$item->getQuantity();
            $order->quantity=$item->getQuantity();

          //$data=(array)$item->options;
            $order->product_image=$item->options['image'];
// print_r($order); die;
            $order->save();

      }
         //print_r(CartProvider::instance()->getCartItems());
      return view('frontend/modules/checkout');
     CartProvider::instance()->destroy();

    }

谢谢你的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-05 19:54:37

根据代码,您为循环中的项目赋予了与html元素相同的名称。你应该定义为数组。例如:

代码语言:javascript
复制
<input type='hidden' name='li_0_product_id[]' value='{{$item->user_id}}' >
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52184452

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档