Post by remb » Sat Nov 22, 2008 10:03 am

Hello again,

First of all, I want to say a big thanks for the great cart ... Congrats to all the people behind it, it's quite a piece of work!

I dived deep in the code, got my hands dirty and I'm really glad I did it because I manged to modify a bit OC to play the way I wanted. It's quite a pleasure working with it and fun. No more headaches  ::)  However, I got to a point where I might need a little bit of push... I added some new custom text fields and file uploaders to the checkout page, according to the quantity and product information (please see the attached screenshot). Now, I need a way to relate my custom information to the current session so when / if the session is destroyed and the order is not carried out, the whole circus also gets wiped out . I already have a new table waiting ready to tuck in the custom information ... but don't know how to pull out the current session_id ...  ???

Any advice would be greatly appreciated!

Thanks a mil.

Attachments

???
Screenshot-Shopping Cart - Mozilla Firefox.png

Newbie

Posts

Joined
Thu Nov 20, 2008 12:08 pm

Post by Qphoria » Sat Nov 22, 2008 11:33 am

Hmm..

I envision that you'd want things to be a little different. Take a look at the site http://www.PersonalizationMall.com. You can add multiple custom lines to products there, but the secret is that each product is it's own product if it is custom.

I'd say instead of trying to add these lines on the cart page for quantities of x2.. you'd need to add text fields as new options to each product. Then all products would be their own product and you'd have the lines associated with each product, which would then keep the circus together as a single "item".

Currently the options only support one type by default, but I'm actually looking at ways to offer multiple option classes (dropdown, text, multi-select, etc)

Then the lines would be set on the product page, and the cart would look more like the attached:

Attachments

???
lines.jpg
Last edited by Qphoria on Sat Nov 22, 2008 11:39 am, edited 1 time in total.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by remb » Sat Nov 22, 2008 12:27 pm

Yes, I understand your opinion and sounds pretty logic however my presentation was the client's choice so I am bound to do it that way. I am thinking that if I can manage to tie it up through a foreign key with the current user session I will also manage to "destroy" it whenever the shopping session is ended. In the end, after updating the information, it will also look as your presentation does.

I think I could do it if there would be a way to keep track of the session_id on the checkout page?

Thank you.

Newbie

Posts

Joined
Thu Nov 20, 2008 12:08 pm

Post by bruce » Sat Nov 22, 2008 12:31 pm

You might like to try simply persisting the data in the cart object so that it has the same lifetime and scope as the list of products and options currently saved there.

This also makes good design sense because the additional information is related to the products selected.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by remb » Sat Nov 22, 2008 12:55 pm

You might like to try simply persisting the data in the cart object so that it has the same lifetime and scope as the list of products and options currently saved there.

This also makes good design sense because the additional information is related to the products selected.
This is also a very good idea... and simpler than what I had in mind. Also, already have in the cart's object the custom text fields structure information that I'm generating the forms based on ... I think I could have the fields contents as well...  :)

Thank you Bruce!

Newbie

Posts

Joined
Thu Nov 20, 2008 12:08 pm

Post by Qphoria » Sat Nov 22, 2008 12:59 pm

remb wrote: Yes, I understand your opinion and sounds pretty logic however my presentation was the client's choice so I am bound to do it that way.
Those are 2 words that don't go together :)

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by remb » Sat Nov 22, 2008 1:27 pm

Qphoria wrote:
remb wrote: Yes, I understand your opinion and sounds pretty logic however my presentation was the client's choice so I am bound to do it that way.
Those are 2 words that don't go together :)
ha, ha, ha ... you're damn right! can't live with them, can't live without them  :D

Newbie

Posts

Joined
Thu Nov 20, 2008 12:08 pm

Post by remb » Sat Nov 22, 2008 10:51 pm

Ok, stuck again. As I said, the idea with persisting the data into the cart object is great but putting the information in the actual products array so it can be handled on cart.tpl it's a mistery to me  ???

Here's what I'm doing

on /catalog/controller/cart.php, function index(), has a condition if ($request->isPost()) and I'm thinking I should do it this way:

Code: Select all

if ($request->get('custom_fields', 'post')) {
       foreach ($request->get('custom_fields', 'post') as $product_id => $fields) {
               // pass $fields to /library/cart/cart.php , $this->products, where the actual products array is built
       }
}
I cannot do it inside the index() function because right after the isPost() condition comes

Code: Select all

$response->redirect($url->ssl('cart'));
and it's killing my $_POST

I'm sorry but just starting to learn Open Cart's structure and I might not be thinking at the best working methods so I really need your help here.

Thanks a lot!

Newbie

Posts

Joined
Thu Nov 20, 2008 12:08 pm

Post by Qphoria » Sat Nov 22, 2008 11:48 pm

Hmm.. lets first try to understand what you are doing.

- You add an item, "Product 1" to the cart.
- On the cart page you want to see the normal cart, and below it you want to see 4 text boxes for that product:

Code: Select all

Product 1:
|_____________________________| Line 1
|_____________________________| Line 2
|_____________________________| Line 3
|_____________________________| Line 4
- Now you add another item, "Product 2" to cart.
- On the cart page you want to see the normal cart with 2 items in it and 4 text boxes for each product

Code: Select all

Product 1:
|_____________________________| Line 1
|_____________________________| Line 2
|_____________________________| Line 3
|_____________________________| Line 4

Product 2:
|_____________________________| Line 1
|_____________________________| Line 2
|_____________________________| Line 3
|_____________________________| Line 4
Now if you update the qty for Product 1 on the cart page you want to see:

Code: Select all

Product 1:
|_____________________________| Line 1
|_____________________________| Line 2
|_____________________________| Line 3
|_____________________________| Line 4

Product 1:
|_____________________________| Line 1
|_____________________________| Line 2
|_____________________________| Line 3
|_____________________________| Line 4

Product 2:
|_____________________________| Line 1
|_____________________________| Line 2
|_____________________________| Line 3
|_____________________________| Line 4
Is that right?

That being the case, you need a form submit to update those fields so you can either at them as part of the update button for the normal cart, or add their own button.

You'd also need to set those fields to match up with a product id so something in the tpl file as part of the foreach loop for products in the cart. Something like

Code: Select all

<?php $i = 0; ?>
<?php foreach ($products as $product) { ?>
..........
#### existing code ####
.........
<input type="text" name="textline[<?php echo $i; ?>][product_data][product_id][1]" value="">
<input type="text" name="textline[<?php echo $i; ?>][product_data][product_id][2]" value="">
<input type="text" name="textline[<?php echo $i; ?>][product_data][product_id][3]" value="">
<input type="text" name="textline[<?php echo $i; ?>][product_data][product_id][4]" value="">
<?php i++; ?>
</php } ?>


Then you can use

Code: Select all

if ($request->isPost()) {
  .........
  if ($request->gethtml('textline', 'post') != null) {
       // do your code
  }
  .......
}
Really its messy. There's no identifier between products in the cart. If you have 10 product 1 items and 50 product 2 items you will have a huuuuuuge list of fields that will get absolutely confusing.

I think you are better off adding it to the product and giving a new proposal to your client...but I digress

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by remb » Sun Nov 23, 2008 3:27 am

Thank you Qphoria !
You are perfectly right, that's the functionality but everything is more organized than I could explain. Please let me pull my thoughts together and I will get back with a better explanation. Meanwhile, if you have the time, please have a look at this live example: http://dev3.e1design.us/ . Each product can have it's own number of custom text fields ... I will also send in a private message with logins to get you access to the backend. You'll notice the new "custom text" tab for the products.

Thank you, I really appreciate you had your time for me !!


Best,
Rem.

Newbie

Posts

Joined
Thu Nov 20, 2008 12:08 pm

Post by remb » Mon Nov 24, 2008 9:48 am

I think I finally managed to pull it out... The custom text fields are working the way I needed but it was easier to use a new table then keeping the data in the cart object. Anyways, I hacked OC with no shame but fortunately, so far, it's working the way I need it to... Maybe in the future, you'll consider a small post with basic guidelines for building OC modules?

Thanks!

Newbie

Posts

Joined
Thu Nov 20, 2008 12:08 pm

Post by jty » Mon Nov 24, 2008 12:41 pm

remb wrote: Maybe in the future, you'll consider a small post with basic guidelines for building OC modules?
A wiki is on the cards. I think Q might have posted something on creating modules in here somewhere
The biggest problem is there's so much to do and so few to help
Q's currently flat chat changing nappies/diapers and coding in sleep mode

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by Qphoria » Mon Nov 24, 2008 12:51 pm

Word!

Once 0.7.9 is out we can really focus on the documentation and stuff. I've been making a faq or two but the team needs to discuss which wiki we want to use, how it should be laid out, etc. so until then we are trying to make them here and there in faqs

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by remb » Mon Nov 24, 2008 5:55 pm

Yeah, I know guys, time is short ... Whenever will be the right time will be just fine and once I'm going to get a good grip on OC, be sure I'll do my best to contribute as well.

Newbie

Posts

Joined
Thu Nov 20, 2008 12:08 pm
Who is online

Users browsing this forum: No registered users and 3 guests