jordscream/cart-bundle

WTF: 简单的购物车电子商务管理

安装: 139

依赖: 0

建议者: 0

安全: 0

星标: 9

关注者: 2

分支: 3

类型:symfony-bundle

dev-master / 0.1.x-dev 2016-04-27 07:43 UTC

This package is not auto-updated.

Last update: 2024-09-24 05:10:47 UTC


README

WTFCartBundle

WTF ! 简单购物车电子商务管理 !

简单

  • 你在项目中有一个产品/项目
  • 你想要在电子商务购物车中添加和删除产品
  • 你想要有一个简单的块来显示购物车中的产品
  • 你想要管理购物车实体

这个WTF Bundle就是为你准备的!

兼容 Symfony 2.3.*

步骤 1: 使用composer下载WTFCartBundle

在composer.json中添加WTFCartBundle

{
    "require": {
        "jordscream/cart-bundle": "*"
    }
}

现在运行以下命令让composer下载这个bundle

$ php composer.phar update jordscream/cart-bundle

Composer会将bundle安装到项目的vendor/jordscream目录。

步骤 2: 启用bundle

在kernel中启用bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new WTF\CartBundle\WTFCartBundle(),
        new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
    );
}

现在添加config.yml到bundle的配置

wtf_cart:
    item_class: App\ProductBundle\Entity\Product (put your Product entity)
    user_class: WTF\UserBundle\Entity\User (put your User entity)

更新数据库和部署web资产

$ php app/console doctrine:schema:update --force --complete
$ php app/console assets:install web

重要

在实体Product中定义方法__toString

使用方法

显示购物车摘要

{{ render(controller("WTFCartBundle:Cart:cart")) }}

在产品中添加购物车添加按钮

{% include "WTFCartBundle:Cart:button.html.twig" with {'itemId' : product.id} %}

-- 简单的WTF --

待办事项

  • 购物车详情页面
  • 清空购物车按钮
  • 单元测试
  • PR :)