lbCartPlugin - 1.0.12

lbCartPlugin

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

alt text

More than a simple commercial cart, the "cart" of lbCartPlugin will receive any object with behavior (actAs) Cartable. Thus, it can be used for the user to reference contacts, books, movies, and any object present on the site, whether commercial or not!

In addition, this plugin recording the data added to the cart in a table will help you make an analysis of products typically associated and thus be able to do cross marketing and so provide items of interest to the user, whether commercial or not.

The several configuration settings will allow you to adjust the cart just as you want, as design as feature. You will soon have access to a video tutorial to see a quick overview of what happens on the site http://leny-bernard.com/fr/afficher/article/lbcartplugin.

  • Requirements and advices

    1. You have to install the sfJqueryReloadedPlugin to be able to have the jquery helper for ajax functions
    2. The cart get all the functionnalities when binded with users. For now, the first version just support the sfGuardUser model, so i suggest you to install sfDoctrineGuardPlugin
  • Tutorial :

  1. you will soon be able to watch a screencast here : Video

  2. you can follow the instructions below

  3. you can follow the instructions in my website : in english : http://leny-bernard.com/en/show/article/lbcartplugin or in french : http://leny-bernard.com/fr/afficher/article/lbcartplugin

Installation:

In order to install the plugin lbcartplugin : Type one of these symfony commands :

    plugin:install lbcartplugin

OR

Download the file here

Then extract its content in the plugins directory of your project and then add this line in the config/ProjectConfiguration.class.php

    $this->enablePlugins('sfDoctrinePlugin','sfJqueryReloadedPlugin','lbCartPlugin');

Get the plugin's resources by typing :

    symfony publish-assets

Then clear the cache :

    symfony cc

A last task to do is to enable the cart module (frontend) in the /apps/frontend/settings.yml config's folder.

all:
  .settings:
    enabled_modules: [default, cart]

You can now access to the cart and get its awesome functionnalities. But for now, you can't add any objects in your cart.

and fill up the correct configuration fields

2 Steps remaining :

  • actAs : Cartable :~ You have to add the Cartable behaviour to the objects you want to be carted For example, if you have a model named Film :

    Film:
      actAs:
        Cartable: ~
        Timestampable: ~
      columns:
        user_id:
          type: integer
          fixed: false
          unsigned: false
          primary: false
          autoincrement: false
    

This Cartable behaviour will automatically create a TITLE, a DESCRIPTION, an AMOUNT, a PHOTO and a CURRENCY linked to the currency table which store the whole world's devises Just set a user_id with (or not) the correct relation

  • Redefine your own configuration in your app.yml

HERE IS THE DEFAULT CONFIGURATION app.yml :

    all:
      lbCartPlugin:
        user_class: sfGuardUser         # [sfGuardUser,member]
        login_field: username           # if you use another user class, define here the login field (Mandatory) 
        login_strict_mode: 1            # 0 => the user haven't to be logged, 1 => he have to be (the cart won't be displayed and won't works).
        object_classes_names:           # set all the objects you've setted up the Cartable behaviour, usefull for a manual cart add (in backend for example)
          - film
          - serie
        css:          /lbCartPlugin/css/cart.css    # set here your own style file
        images_path:  /lbCartPlugin/images/     # set here your home path which will contain your 4 next button's images
        images:                 # define the name of the button's image
          add:      add_48.png
          show:     show_48.png
          delete:   delete_48.png
          loader:   ajax-loader.gif
        labels:                 # define the button's title attributes
          add:      + Ajouter à mes favoris
          show:     Afficher mon panier
          delete:   Vider mon panier
          loader:   Enregistrement en cours

*user_class

The user_class_configuration define the kind of users used in your application. For this first version, you can use sfGuardUser or Member. If you choose Member, you just have to set a user attribute (in session) named as you mentioned in the login_field configuration item. Thus, if the user is connected (if not, define this function : $user->isAuthenticated()), we have to get the login by this function $user->getAttribute('login');

Then Build all and load for the currencies :

    symfony build --all --and-load --no-confirmation

=== HOW TO USE ===

Now, you will have to include the buttons in the view. You can add the component by adding those lines :

    <?php include_component('cart', 'editbox', array('model' => 'film','id' => $myObject->getId(),'actions'=>array('add','delete','show'))) ?>

You can set the buttons to display by passing an an array named "actions". The plugin is in a beta mode, some configurations will follow.