我正在尝试向我的 Laravel 应用程序添加购物车功能。我从 GitHub 安装了 darryldecode/laravelshoppingcart 包,并按照这两个网站中的说明进行操作。
\n\nLARASHOUT-Laravel 电商应用开发 \xe2\x80\x93 结帐
\n我能够使用第一个网站创建大部分购物车功能,但它不包括结帐和下订单,因此我找到了第二个网站。
\n问题是合同文件不起作用。这是我得到的错误。
\n\n\nIlluminate\\Contracts\\Container\\BindingResolutionException\n目标 [App\\Contracts\\OrderContract] 在构建 [App\\Http\\Controllers\\CheckoutController] 时不可实例化。\nhttp://localhost:8000/checkout
\n
我使用合同文件的地方是在结帐过程中,第二个网站对此进行了解释。我对代码做了一些更改,以便它与第一个网站保持一致,但大多数情况下我遵循网站的说明。
\n以下是错误中提到的代码。
\n订单合同.php
\n<?php\n\nnamespace App\\Contracts;\n\ninterface OrderContract\n{\n public function storeOrderDetails($params);\n}\n
Run Code Online (Sandbox Code Playgroud)\nCheckoutController.php
\n<?php\n\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\nuse App\\Contracts\\OrderContract;\nuse App\\Http\\Controllers\\Controller;\n\n\nclass CheckoutController extends Controller\n{\n protected $orderRepository;\n\n public function __construct(OrderContract $orderRepository)\n {\n $this->orderRepository = $orderRepository;\n }\n\n public function getCheckout()\n {\n return view(\'checkout\');\n }\n\n public function placeOrder(Request $request)\n {\n // Before storing the …
Run Code Online (Sandbox Code Playgroud) 我正在购买购物车,我的问题是,我应该如何设计数据库来选择产品的尺寸?T恤可以是"XL,L,M,S"等.鞋子可以是"36,37,38,39 ...... blabla"我应该只做一个尺寸的桌子或多种类型的桌子(T恤,鞋子等) )?
提前致谢...
客户需要能够让他们的购物车自动检索并保持至少美国的最新销售税表,并且最好是所有与美国签订税收协定的国家.这是一个合理的要求吗?托管解决方案很好.
我正在用PHP制作购物车.要检查用户是否选择了多个产品,我将所有内容都放在一个数组中($ contents).当我输出它时,我得到类似"14,14,14,11,10"的东西.我想要像"3 x 14,1 x 11,1 x 10"这样的东西.最简单的方法是什么?我真的不知道怎么做.
这是我的代码中最重要的部分.
$_SESSION["cart"] = $cart;
if ( $cart ) {
$items = explode(',', $cart);
$contents = array();
$i = 0;
foreach ( $items as $item ) {
$contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;
$i++;
}
$smarty->assign("amount",$i);
echo '<pre>';
print_r($contents);
echo '</pre>';
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我正在寻找一个好的购物车到我的新店铺网站.我脑子里几乎没有想法开始开发它......
ShoppingCart
,ShoppingCartItem
,ShoppingCartEvent
,OrderHandler
,等}我正在寻找这个问题,关于你的经验,是开发购物车的最佳方式(更容易处理)?
成为有状态的ejb是好事吗?购物车必须具备哪些常见对象及其功能(方法)?...
谢谢,任何帮助和建议将不胜感激.
我已经建立了一个由Magento 1.4.2社区版驱动的B2B站点.有时,客户会尝试在购物车中检查大量物品 - 最多250个!我的问题有两个方面:
有没有人在处理这类问题时有类似的经历?
我试图实现memcached以及整页缓存,希望它可以帮助减轻服务器的一些压力,但它没有有效地解决这个问题.
我是magento的初学者.我需要将动态价格从详细页面传递到购物车.
现在,当我通过动态价格时,它没有在购物车中更新,而是由产品的原始价格取代.
任何帮助将不胜感激.在这一行,我得到了价格.$price=$this->getRequest()->getParam('price_custom');
Indexcontroller.php
public function cartAction()
{
if ($this->getRequest()->getParam('cart')){
if ($this->getRequest()->getParam('cart') == "delete"){
$id = $this->getRequest()->getParam('id');
if ($id) {
try {
Mage::getSingleton('checkout/cart')->removeItem($id)
->save();
} catch (Exception $e) {
Mage::getSingleton('checkout/session')->addError($this->__('Cannot remove item'));
}
}
}
}
if ($this->getRequest()->getParam('product')) {
$cart = Mage::getSingleton('checkout/cart');
$params = $this->getRequest()->getParams();
$related = $this->getRequest()->getParam('related_product');
$price=$this->getRequest()->getParam('price_custom');
$productId = (int) $this->getRequest()->getParam('product');
if ($productId) {
$product = Mage::getModel('catalog/product')
->setStoreId(Mage::app()->getStore()->getId())
->load($productId);
try {
if (!isset($params['qty'])) {
$params['qty'] = 1;
}
$cart->addProduct($product, $params);
if (!empty($related)) {
$cart->addProductsByIds(explode(',', $related));
}
$cart->save(); …
Run Code Online (Sandbox Code Playgroud) 我找到了很多问题的答案,但有些是矛盾的,而且很多都不完全清楚,所以我希望Magento专家可以指出我正确的方向.
对于Magento中的某些产品,有一个复杂的定制过程.有一个自定义编辑器,每个"设计"都由一个唯一值标识.我需要的是将此ID与产品一起存储在购物车和订单中.它不应该直接显示,而是可以在代码中访问(例如,在购物车中显示不同的缩略图或发票上的某些信息).
此外,由于产品是定制的,如果此ID不同,同一产品应在购物车和发票中有单独的行!
例如,客户打开产品页面,进行一些自定义,此自定义获得ID"1".客户将其放入购物车.他再次打开相同的产品,以不同的方式定制它,并获得id"2".客户也将其放入购物车!
购物车现在应该是:
并不是:
但是,客户仍然可以订购多个具有相同ID的相同产品!所以,例如
定制发生在magento之外.Magento只是有一个弹出窗口的链接,然后获得一些ID,然后可以使用PHP附加.它只是存储ID,并且必须能够获得购物车/发票/中的每个产品的ID ...
重要的是,如果ID不同,则存储ID并且具有相同sku /可自定义选项的产品不会合并到购物车中!ID也必须是文本字符串,而不是像magento自定义选项那样从列表中选择!
方法我发现可能做我想要的:
http://www.atwix.com/magento/custom-product-attribute-quote-order-item/ 这对我来说是最好的,有一个我可以修改的完成模块.但我不确定这是否是正确的做法.产品是否会在购物车中分开?此外,ID的值在此处设置为Product选项并在后端可见?!在客户根据我的情况定制产品之前没有任何价值!
https://magento.stackexchange.com/a/1382 我不太确定......如何在观察者的内部获得产品详细信息页面上的ID ...
如何将每个产品作为新项目添加到购物车 中除了1.或2.我还需要修改它.
如果Magento专家可以为我发光,我将不胜感激!
所以我正在尝试使用购物车创建一个应用程序,当我尝试添加该项目时,它无法正常工作.顺便说一句,我已经有一个工作车应用程序,这就是为什么我想知道为什么它不工作.我几乎从工作中复制了所有东西.这是代码
推车控制器
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Cart extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->library('cart');
}
public function add_to_cart(){
$id = $this->uri->segment(3);
if($this->cart->contents()){
foreach ($this->cart->contents() as $item){
if ($item['id']==$id){
$data = array('rowid'=>$item['rowid'],
'qty'=>++$item['qty']);
$process = $this->cart->update($data);
}
else{
$data = array(
'id'=>$id,
'qty'=>1,
'name' => $this->get_data->get_value('product_name','products','product_id', $id),
'price' => $this->get_data->get_value('product_price','products','product_id', $id)
);
$process = $this->cart->insert($data);
}
}
}
else{
$data = array('id'=>$id,
'qty' =>1,
'name' => $this->get_data->get_value('product_name','products','product_id', $id),
'price' => $this->get_data->get_value('product_price','products','product_id', $id), …
Run Code Online (Sandbox Code Playgroud) 尝试使用它while loop
来回显数据库中的prod_qty
和prod_desc
字段.没有错误.我也试过使用foreach loop
你在代码中看到的,但它没有显示任何东西.
这是cart.php文件:
<?php
// 1. Establish a connection using three functions: 1. mysqli_connect() 2. mysqli_connect_errno() 3. mysqli_connect_error()
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "shoppingcart";
$connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
// Test if connection occured
if(mysqli_connect_errno()) {
die("Database connection failed " . mysqli_connect_error() . "( " . mysqli_connect_errno() . " )");
}
// Show the products by performing a query to database. …
Run Code Online (Sandbox Code Playgroud) shopping-cart ×10
php ×5
magento ×3
mysql ×2
cart ×1
checkout ×1
codeigniter ×1
database ×1
dynamic ×1
e-commerce ×1
ejb ×1
foreach ×1
frequency ×1
html5 ×1
java ×1
laravel ×1
magento-1.4 ×1
sales-tax ×1
while-loop ×1