Saturday, May 29, 2010

[LONG] 1.2.7, Application and plugin intercommunication, looking for ideas, comments, etc.

Hi all,

I have started to look into how to integrate a cart plugin and a
paypal payment plugin without having either of the plugins knowing
anything about each other as well as the application.

First I would like to hear comments and ideas on the use of the cart
plugin.

In the application, the user can reserve a featured position on the
site for one or more weeks (monday to sunday). The reservation is
shown in a calender like widget for the current year plus the upcoming
year. Each calender shows the free weeks, the taken weeks, the
reserved weeks (by the user) and the past weeks.

Each reserved week should also be added to the cart and here is where
I have some issues and certainly would be happy for any ideas and
comments on how to realize it.

As the cart is a plugin, it can't assume anything about the
application, except that the current user may be found using the Auth
component. (comments?)

So my idea was to realize the cart interface using a CartComponent,
defined in the cart plugin, but usable by the application. The
CartComponent provides the application with the methods to:
- open: Get the current cart or open a new one.
- add: Add an item to the cart.
- remove: Remove an item from the cart.
and others to come later, but first I wish to crystalize my idea :)

The CartComponent then communicates with the cart plugin using
requestAction. Thus it is not necessary for the application to know
more about the cart plugin than the interface that the CartComponent
offers. (comments?)

In order to view the cart content, the cart plugin provides a cart
element showing the content of the cart (presented below the
calenders) and providing the user with actions to remove a cart item.
These actions invokes the plugins CartController which then removes
the item from the cart.

My issue here is how do I inform the application of the need to cancel
the reservation?
1) Do I configure the cart plugin, so that it knows how to cancel the
reservation?
2) Do I configure the CartComponent, so that it knows how and the
plugins CartController can use the same CartComponent to cancel the
reservation?
3) Do you have any better/other ideas?

Cart plugin models:
CartModel
- id, user_id, state, currency_code, description, created;

CartItemModel
- id, cart_id, model_name, model_id, item_line_0, item_line_1, price,
quantity;
where model_name and model_id points back to the originating model, in
this case the application model for featured positions.

Looking forward to hear your comments,
John

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: