【问题标题】:php cart not sending through more than one item to paypalphp购物车没有通过多个项目发送到贝宝
【发布时间】:2014-10-11 01:41:47
【问题描述】:

我创建了一个购物车,但由于某种原因它没有向贝宝添加其他商品。它只发送一个项目。我有要添加到数据库中的项目列表,然后循环遍历它们。

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="test@test.com" />
<div class="basket_block" id="basket_block">
  <div class="checkout_inv" id="checkout_inv">Invoice: OCA1234</div>
<?php 
$sql_cart="SELECT * FROM cart_table where session_id = '$sessionid'";
$result_set_cart=$database->query($sql_cart);
$num_rows_cart=$database->num_rows($result_set_cart);
for($i=1;$i<=$num_rows_cart;$i++)
{
while ($row_cart=$database->fetch_array($result_set_cart)){  

    $prod_id_now=$row_cart['products_id']; 
    $quantity_now=$row_cart['quantity'];
    $grand_total_now =$row_cart['grand_total'];

    $sql_product = "Select * from products where id = '$prod_id_now'";
    $result_set_product = $database->query($sql_product);
    while ($row_product=$database->fetch_array($result_set_product)){ $titleofmessage = $row_product['Title_of_Message'];       $type_id = $row_product['type_id'];}
    $sql_type = "Select * from type where id = '$type_id'";
    $result_set_type = $database->query($sql_type);
    while ($row_type=$database->fetch_array($result_set_type)){ $typename = $row_type['name'];}
?>
  <div class="checkout_des" id="checkout_des">  <?php 
  echo 'Title: '.html_entity_decode($titleofmessage).'<br>'.'Tpye: '.$typename.'<br>'.'Quantity: '.$quantity_now."<P>";
  ?></div>

  <div class="checkout_amount" id="checkout_amount"><?php echo 'R '.number_format($grand_total_now,2); ?></div>


    <input type="hidden" name="item_name_<?php echo $i; ?>" value="<?php echo html_entity_decode($titleofmessage); ?>" />
    <input type="hidden" name="quantity_<?php echo $i; ?>" value="<?php echo $quantity_now; ?>" />
    <input type="hidden" name="amount_<?php echo $i; ?>" value="<?php echo $grand_total_now; ?>" />  
<?php
}
}
  ?> 


</div>

【问题讨论】:

    标签: php for-loop paypal shopping-cart


    【解决方案1】:

    只需添加 $i++;你需要增加你的循环

    <div class="checkout_amount" id="checkout_amount"><?php echo 'R '.number_format($grand_total_now,2); ?></div>
    <input type="hidden" name="item_name_<?php echo $i; ?>" value="<?php echo html_entity_decode($titleofmessage); ?>" />
    <input type="hidden" name="quantity_<?php echo $i; ?>" value="<?php echo $quantity_now; ?>" />
    <input type="hidden" name="amount_<?php echo $i; ?>" value="<?php echo $unit_cost; ?>" /> 
    <?php
    $i++;
    }
    }
    ?> 
    

    【讨论】:

      猜你喜欢
      • 2013-02-28
      • 2010-12-18
      • 1970-01-01
      • 2017-11-18
      • 1970-01-01
      • 2015-09-02
      • 1970-01-01
      • 2012-09-10
      • 1970-01-01
      相关资源
      最近更新 更多