Search

Hi

I’d like to ask a community to test my shopping cart extension and ensemble.

It’s quite raw and not fully tested by me, so, I don’t want to publish it at Extensions/Ensembles sections yet.
Nevertheless, it looks like extension works well in the ensemble.

Standalone Shopping Cart extension

Installation

First of all, the extension requires one small hack of class.frontendpage.php. You should add ‘ManipulatePageParameters’ delegete to it:

/symphony/lib/toolkit/class.frontendpage.php
After line 233:

$this->_events_xml = clone $events;

Add:

$this->_Parent->ExtensionManager->notifyMembers('ManipulatePageParameters', '/frontend/', array('params' => &$this->_param));

Thats all with hacking) After that install extension as usual.

Then go to System/Preferences and choose a Price field. Extension will take price values for calculations from that field (This implies, that you already have section with appropriate fields for a shop).

Usage

After installation you’ve got a Shopping Cart event, datasource, and new page params

Event

In theory Event should accept both GET and POST request, but I’ve been tested it with GET only.

Accepted variables are:

  • action (accepted actions are: add, drop, recalc, dropall)
  • id (system id of item)
  • num (number of items)

Say, if you want to add one item to Cart, your GET request should be:

?action=add&id=42&num=1

For dropping item from cart:

?action=drop&id=42

For recalculating:

?action=recalc&id=42&num=5

After processing event returns event XML:

<events>
    <cart>
        <msg result="added|dropped|recalc|dropall|error">Text Message Here</msg>
    </cart>
</events>

Data Source

It’s quite simple here:

<shopping-cart>
    <item id="9" num="2" sum="599.98" />
    <item id="8" num="1" sum="41" />
    <item id="7" num="1" sum="22" />
</shopping-cart>

Page parameters

Extension append three new parameters to a page:

  • $cart-items - System id’s of items at cart
  • $cart-items-num - Number of items at cart
  • $cart-total - Total cost

If Cart is empty, extension returns just $cart-items = ‘empty’

Looks like that’s all instructions. Anyway, I think, for start it’s better to install and dig Shopping Cart Ensemble for make things clearer.

Any questions and suggestions are welcome.

Attachments:
Shopping-Cart-ensemble.zip and shoppingcart.tar.bz2

This is great, andrrr.

I haven’t tested it but I have a question though: Is it really necessary to hack the core to get things working?

This is awesome… I haven’t tested, but for sure I will!!!

I quickly tested the ensemble, It it seems to work fine! Very simple… A very good starting point for me to understand how to build my own shopping cart… I will spend some time exploring it. Thanks a lot!

Cheers!

Is it really necessary to hack the core to get things working?

The FrontendParamsResolve delegate is there for the same purpose.

@Nils, @nickdunn
The FrontendParamsResolve delegate starts before Events processing. In this case cart’s page params will not show actual cart status after Event call.

The only alternative I can see here is to completely drop page params feature and make use of a data source. As a result we could not do filtering shop items by $cart-items (we need it at cart’s page) and should save to session more data about added items (item title and price at least). Such a dilemma.

At my point of view usability of a page params feature costs that hack.
Please, correct me if i miss something.

@brunopinho78 You’re welcome) I think i’ll release it in a few days.

@brunopinho78
Have you discoverd some new uses?

@andrrr
Do the new delegates and tweaks in version 2.0.7 mentioned here make this extension possible without the hacks?

@newnomad

The extension is already available without any hacks. Check here, please

p.s. I think it’s better to close or delete this thread as it is not relevant any more

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details