WebShop, session and transaction

Author Message

Arnaud Lafon

Monday 21 August 2006 1:22:13 am

Hi the eZCommunity ;)

Monday, 9am, hard to wake up but...

I have a problem & interrogation about the webshop module of eZpublish. First, If someone have ever looked in the shop core and could tell me how it works (what file does what ...), it would be very helpfull :)

What I want to do :

pre. : I've added a quantity of available products in the product class.
1. I want to decrease this quantity when someone <b>add this product to his basket</b> (even if he does not confirm his order at this moment)
2. I want to keep this product reserved for this user for a determined time until he confirms the order (or not -> the product is then available)

So, my interrogations are :

- Shall I go into an extension dev. or just do something into the core ?
- How user basket is managed in the shop module ? I had a look into the database, but it seems that's not here... Maybe session variable ?
- I'd like to make this with transaction (to provide me rollback if server crashes or something like that...) and to keep the database informations real... Does the system already do this that way or not ?

Thanks a lot,

Regards,

Arnaud

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

Arnaud Lafon

Monday 21 August 2006 3:11:46 am

Well, forgot what i've said about the basket management... I did not see the ezbasket table... yes I know... I must check my eyes... :D

There are lot of information I dont understand how it works...
- productcollection_id who relates to the ezproductcollection table wich relates itself to the ezproductcollection_item table
- order_id ......... ezorder table ....... ezorder_item
- and a session_id...

what i don't understand is that the ezbasket isnt empty although I'm the only one accessing the site... and i dont have anything in the basket... even if I clear all the session using the ez admin interface...

something else, I don't understand why I have some line in the ezproductioncollection table without order_id...

any idea ?

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

Nicolas Lescure

Tuesday 22 August 2006 12:28:03 am

Hi,

I'm also working on the workshop actually, and I have some problems too :)
I can tell yu what I know on your problem :

the ezorder table have an attribute called "duct collection". You can find the same in the table esproductcolection_item. It's a kind of foreign key in fact.

If you are working on an extension, you can use the classes to modify and store the modification. But I still don't know exctly how...

Arnaud Lafon

Tuesday 22 August 2006 1:41:43 am

Hi,

thx for replying :) I also found this key and the others tables...

Now I can say :

<b>Adding a product to the basket</b>

- add an entry in ezbasket(id, order_id, productcollection_id, session_id)

order_id = 0

- add an entry in ezproductcollection(created, currency_code, id)
- add an entry in ezproductcollection_item(contentobject_id, discount, id, is_vat_inc, item_count, name, price, productcollection, vat_value)

discount : discount value
price : price including VAT
vat_value : VAT percent value

<b>Deleting a product form the basket :</b>

- delete the entry in ezproductcollection_item
- <i>currency_code</i> attribute is set to blank in ezproductcollection for the related entry

<b>Order Confirmation</b>

<b>Step 1 - Click the Checkout button (in the Basket view) and then Continue button (in the Client information confirmation view)</b>

- add an entry in ezorder(accound_identifier, created, data_text_1, data_text_2, email, id, ignore_vat, is_archived, is_temporary, order_nr, productioncollection_id, status_id, status_modified, status_modifier_id, user_id)

data_text_1 = xml text to recap customer information
is_temporary = 1
email = blank
order_nr = 0

- in ezbasket

order_id link to the ezorder.id

- in ezproductcollection

currency_code set to blank ??? (I must check it again...)

<b>Step 2 - Order confirmation (just after the call to the payment gateway)</b>

- in ezbasket

order_id set to blank, and entry is still here

- in ezorder

email = customer mail
is_temporary = 0
order_nr = incremented (but != order_id)

- in ezproductcollection

entry duplicated (-> new id)

- in ezproductcollection_item

entries duplicated (-> new id)

<b>In Conclusion : </b>

- if you delete the basket content

there is still and entry in ezbasket (-> can't understand why...!!!)
if then you add again a product in the basket
		§	the entry in ezbasket stay there
		§	a new entry is created in ezproductcollection_item (if it's the same product, only the id differs from the last entry because it's a unique & autoincremented key)

- if you don't confirm the order

nothing done, you can call the page by using shop/confirmorder
if you add an other product in the basket :
		§	same product -> only the quantity changes in ezproductcollection_item
		§	new product -> new entry in ezproductcollection_item (with the same productcollection_id)
if you delete the product from the basket
		ð	delete the entry in ezproductcollection_item
		ð	<i>currency_code</i> attribute is set to blank in ezproductcollection for the related entry, but the entry is still there... and if you delete the basket, then add a product, the created attribute IS NOT change
		ð	the entry in ezorder is still there too. You can still access to the order by shop/confirmorder but there is no article inside (normal...)

...

so I'm lost...

There are many things that I can't understand (why there is still an entry in ezbasket or ezorder...)
For the quantity management, I'd like to do this (unless there is someone who give me a better solution ;) :
- creating a function (or a template operator) to check the available quantity of the product in the product information and decrease this (virtually, I mean I don't modify the database entry for a product) each time it found an entry in ezproductcollection_item (related to an ezbasket)
- if someone confirm his order, decrease the product quantity
- creating something who permanently check the creation time in ezproductcollection creation time (the created attribute) and autodelete entry from customer client If the reservation time elapse -> problem if you delete product from basket then add new product, the created attribute isn't reset to the current time... and I really don't know how to do that :s

I know I'm not clear... but If someone could help, It would be very very nice :)

Regards,

Arnaud

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

Nicolas Lescure

Tuesday 22 August 2006 3:20:10 am

Me again,

I'm working exctly on the same thing. After my workflow (payment), my order is done and paid, but the items are still in the basket. It seems you have the same problem... I'll try to modify the classes or make a script to make it empty.

PS: why speaking english since both of us are french ;) ?

Arnaud Lafon

Tuesday 22 August 2006 4:15:06 am

I've juste tried to run the cronjob routine (runcronjob.php) which is supposed to clean the expired basket ... without good result :(

@ Fiber
When you said you still have product in the basket when the order is confirmed, is it in the site basket or in the ezbasket mysql table ?

PS: Why speaking english ? Cuz, I still hope someone help us :)

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

Nicolas Lescure

Tuesday 22 August 2006 5:15:08 am

Yes! In the website, (shop/basket) my basket is still full!

That means, if you haven't this problem, I've skipped a step. And this step can clean the basket!

Btw, I'm working on ezPublish 3.8.1.

Arnaud Lafon

Tuesday 22 August 2006 5:40:58 am

Aïe... I don't have this problem... I'm just asking why the table isn't empty after the order confirmation...
If you don't use the payment gateway workflow, do you still have the problem ? If yes, I think you should check if the payment gateway returns the good value...

As far as I'm concerned, I decided to write an extension that provide me a workflow which make the site waiting 5 seconds before continuing (useful for serverload test).

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

Nicolas Ottavi

Wednesday 23 August 2006 2:57:51 am

Hi there,

As a french too, I would really appreciate to share with you two. If you can why not join other ez french devs on the #ezpublish-fr irc channel (freenode servers).

Concerning the ezbasket table, I think (never tested) that the basket_cleanup.php scripts in the cronjob directory is dedicated to this.

Talk to you soon,
Nicolas

Arnaud Lafon

Wednesday 23 August 2006 4:30:58 am

Hi Olivier,

the basket_cleanup.php script does not do this unfortunetly :(
I think it's only dedicated to clean baskets when a customer session expired.

Incoming soon on your IRC channel

Arnaud

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

Arnaud Lafon

Wednesday 23 August 2006 5:00:46 am

Having problem to connect your server/channel :(
I'm not sure IRC connections are allowed to our company private network... :(
Tell me if I'm wrong... Freenode address is irc.freenode.net ?

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

Nicolas Ottavi

Thursday 24 August 2006 1:53:37 am

Hi Arnaud,

Yes: irc.freenode.net / #ezpublish-fr

Bad to read you can't access it ... It is very useful for sharing experience and get quick help. I 'm learned a lot through this medium.

Regards,
Nicolas

Nicolas Lescure

Thursday 24 August 2006 7:50:16 am

Hi there!

I hope you have good news and you managed to do what you want.
I did some work on the shop (a payment gateway, some template operators) and I begin to understand some things, especially in the eZUser and eZOrder classes.

Do you still have problems?

Arnaud Lafon

Thursday 24 August 2006 8:33:20 am

Hi Fiber,

I'm now able to manage quantity for my product but I still have problems :
- even if I set the quantity attribute to untranslatable, It looks like I still have to check all translated version of the product and decrease the quantity value for each version ... Maybe I missunderstood something about the "Disable translation" checkbox when editing a class... :s
- I'm still thinking how I will manage the product reservation prossess... May I decrease the quantity each time an object is added to the basket & then re-inscreasing the quantity If the reservation time is elapsed (or If the product is removed from the basket) ? May I check the available quantity before adding a product to the basket ? .... :/ I still dont know...

Btw, what operator did you create ?

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

Nicolas Lescure

Friday 25 August 2006 2:16:21 am

Just two little operators, my first ones :)

The first get all orders of a customer, and the second only the last order.
Nothing very difficult as you can see.

I can't help you for your translation problem :/

I'm now workink on a workflow extension. Is it possible to add my own trigger?

Stuart Fenton

Monday 08 January 2007 9:43:32 am

I wrote a simple stock check extension that may help you. It can be found here: http://ez.no/community/contribs/workflow/ezsimplestockcheck

You can create your own triggers but you have to hack the kernel for this as there's no easy way to do it.

-- Stuart

[email protected]
http://www.grandmore.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.