Forums

Add articles to Shopping Cart

Ademma 21 Jul, 2014
Hi there!

I searched the whole Forum for an answer ut i couldnt find one😟

So here is my question:

is it possible with chronoforms to add some articles in joomla into something like a shopping cart?

Background: one of my client is renting some products. every product got its own article. i want to have one single form below every product / article so the user can add the articles with renting duration into the cart. after clicking on the cart chronoforms have to send out an email without payment process, just an email...

how to do that?

using CF5 and Joomla 2.5

Thanks for support!
Robert
GreyHead 23 Jul, 2014
Hi Ademma,

That should be quite straightforward. You will need to capture the id of the product on the current page. If that, or the product name, is in the page URL then you can grab the url and add that to your form in a hidden input.

Bob
teazmo 17 Sep, 2014
Hi Bob,
I would like to create some sort of shopping cart for my website, too. The user is supposed to read about an event and then choose a date, where he or she would like too attend this event. The datelist is actually a form. After submitting the form should send the id/the event-number to my 'shopping cart' or the first page in my chronoform-form. There the user should have the ability to enter his or her address etc and event number and address would be sent as an email to my customer.

1.After reading the reply above, could you please tell me how the URL or action-parameter from the form outside of chronoforms should look like?

2. I added a hidden input-field to my first page in my chronoform-form, but I don‘t know what to type in and where.

using CF5 and Joomla 2.5

Thanks for support!

teazmo
GreyHead 17 Sep, 2014
Hi teazmo,

I would give each event a unique ID - a short random string. then include that in the URL from the first form e.g. &event_id=xx99xx

You can then use this to look up the event details in the form.

Bob
teazmo 17 Sep, 2014
Hi Bob,

Thansk for your answer. Actually I used a unique ID and my URL (action-parameter in first form) : 'index.php?option=chronoforms5&chronoform=mail&number=xx99xx'

1. Is this correct?
2. What do I have to do inside of Chronoforms to fetch that information (number)?

Thanks
GreyHead 17 Sep, 2014
Hi Ademma,

If you add a Debugger action to the form ON Load event you'll see that it is automatically added to the $form->data array

Bob
teazmo 25 Sep, 2014
Hi Bob,

I added the Debugger to the form and my event number showed up – thanks for the hint. Now I would like the first page of my shopping cart to be a list of all event numbers chosen – like a real shopping cart. So that after the user has chosen one event he can return to the event pages and add another event to the 'shopping cart', which means his or her event items have to be collected somehow. So far my original event numbers are overwritten by the new numbers chosen. What do I have to do to collect all numbers? And how can I put session dat into a form?

using CF5 and Joomla 2.5. Thanks, teazmo
GreyHead 27 Sep, 2014
Hi teazmo,

I would use some custom PHP to save the selected events into the User Session - probably as an array of values.

ChronoForms has some of this built in if you add the values to a sub-array like $form->data['selected_events'][]

Bob
teazmo 14 Oct, 2014
Hi Bob,

Today i added Custom Code to the Setup of my code:
<?php $form->data['events'][]  = $_POST[event]; ?>
to save the event number to the form. Looking at the debugger the form grabs the new array and saves the event number to it :
[events] => Array
      (
        [0] = > 234
      ) 
:D
but when i go back to the event pages and choose another event it starts all over again
[events] => Array
      (
        [0] = > 123
      )
:?
How can I 'push'/add the new number to my event array, so I have a real 'shopping cart'? Thanks
GreyHead 15 Oct, 2014
1 Likes
Hi Robert,

Ah, sorry I misunderstood the way you want this to work.

I think that you need to save the cart data to the User session in the On Submit event of the form. Use a Custom Code action with code like this in it.
<?php
$session = JFactory::getSession();
$cf_cart = $session->get('cf_cart', array());
$cf_cart = array_merge($cf_cart, $form->data['events']);
$session->set('cf_cart', $cf_cart);
?>
!! Not tested and may need debugging !!

This should get any existing saved events from the session, add a new event to the array and then re-save it.

When you come to checkout you can use the first couple of lines to get the saved data.

You may need to extend this code to allow for removing saved items too.

Bob
teazmo 23 Oct, 2014
Hi Bob,
Thanks for the support! I have tested your session code and it works very well! 😀 But instead of the OnSubmit event I've used the Onload event to fetch the session infos right away. My question: How can I remove saved items inside of the form (like you said in the last line)?

teazmo
GreyHead 23 Oct, 2014
Hi Robert,

Hmmm . . . I think I would use a form that creates a list of what is in the cart and has a delete link for each item. That link would point to a form event i.e. index.php?option=com_chronoforms5&chronoform=form_name&event=delete&item_id=999

Then in that form event you'd get the session info back again, remove the item with id=9999 resave the cart data and then re-load the list display.

Bob

PS You could also do this with ChronoConnectivity but a simple list in a ChronoForm is probably easier.
teazmo 26 Oct, 2014
Hi Bob,
Today i used a form that creates a list of all event items. Actually I put form-tags around the event(output) and added an input-button 'delete' to each item. Somehow my custom form doesn‘t work. Using Firebug I can‘t see any form except the chronoform-form. Are custom forms not allowed? Or do I have to use two HTML render form in the Setup? How can one form point to one event and another form to another event?

Thanks,

teazmo
GreyHead 26 Oct, 2014
Hi teazmo,

I really can't work out what you are describing here.

You can include custom code in a form using a Custom Element element. What you can't do - because it is illegal HTML is to nest one <form> tags inside another <form> tag - then neither form will work.

Bob
teazmo 28 Oct, 2014

I think I would use a form that creates a list of what is in the cart and has a delete link for each item. That link would point to a form event i.e. index.php?option=com_chronoforms5&chronoform=form_name&event=delete&item_id=999



Hi Bob!
What I wanted to do is what you described above: I created a form, looped through the content of my session array and made a list out of it. Then I added a 'Delete'-button for each individual list-item. Unfortunately the form I've created doesn’t work, probably because I already work inside the chronoform-form (nested forms are not allowed - like you've said). Should I use Javascript/AJAX instead? I want to be able to remove items from my list without leaving the page and to submit the final result to the next page. :?

Thanks for the support. Timo
GreyHead 28 Oct, 2014
Hi teazmo,

I think that this depends where the main cart record is. If it is the list on the page then you can use local JavaScript to remove that line item (or possibly just disable it in case the user whats to change their mind). Then the cart will be updated when the form is submitted.

If the main record is on the server then I think you have to do that using Ajax to call back to the server to record the deletion combined with some JavaScript to remove the deleted item form display once the Ajax call has successfully completed.

Bob



Bob
This topic is locked and no more replies can be posted.