Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[request] Add to wishlist / basket
Hi guys,
I’m not sure if this is possible with plugins that are already written, but here goes..
What I have is a client who hires out bouncy castles and other similar goods. What we would like to do is under each product have a button that lets you add the product to a wish list. I must note that we don’t need a full e-commerce site at the moment, the site is not intended to take any payments just yet.. What we’d like users to be able to do is fill up their wishlist and have that list emailed to us to put a quote together. We’d like the option to show the cost, but it’s not as important as being able to put a package together and sending it to us by email..
I hope someone out there has an idea of where we should start.
Kind regards,
Carl
Offline
Re: [request] Add to wishlist / basket
Hi Carl,
this should be possible to achieve with zem_contact_reborn, at least if you do not need to save the basket for future visits. I hope more knowledgeable people could provide you some help if necessary.
Edit: though it will probably require some javascript skills if the products are not all on the same page.
Last edited by etc (2012-09-17 11:09:58)
Offline
#3 2012-09-17 13:22:03
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: [request] Add to wishlist / basket
I remember we had a wishlist widget tip here in the forum some time ago. I can’t say if it does what you need, I’ve not yet read it, just set a bookmark.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Offline
Re: [request] Add to wishlist / basket
I think this may be more complex than I first thought.. I have downloaded and tried out Simplecart.js 2.0 and I can get it to add product to basket etc. It also works really well with Paypal, but I need to be able to email the order and not go through Paypal..
Another problem that I hadn’t thought about was that I need the user to be taken to a form first that allows them to add their name, contact details etc and then email me that info along with the contents of the cart. I think I need to start learning some php and jquery if I’m ever going to get this to work…
Offline
Offline
Re: [request] Add to wishlist / basket
carlahearne wrote:
What we’d like users to be able to do is…
Expanding on what etc said, when you say ‘users’, are they physical entities — Admin->Users — in the Txp database that you want to attach the data to, or just visitors to the site? If it’s the former then you’ll need to find a way to post the data to the database for later retrieval.
For plain visitors, a lick of jQuery and cookies ought to be sufficient to keep track of a session-based wish list. It could persist, depending on how long you set the opt-in cookies for, and if your visitors come back from the same computer so you can retrieve them.
For the e-mailing portion, I’d be tempeted to try zem_contact_reborn with hidden (secret?) fields which you can populate with the wish list items via jQuery when the person clicks the “I want to tell you about my wishes” button.
If that sounds like it’d work for you then I’m sure someone here can help you out implementing it.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: [request] Add to wishlist / basket
Bloke,
You’ve hit the nail on the head in terms of what I’m looking for.. A user will be a plain visitor, so not linked to the back end in any way. I want them to be able to click on a button which like you say, using jquery will ‘Add to wishlist’. When they have selected the objects / items they want, they click on a button which will take them to a contact form that is pre-filled with the items they chose. They can then add their name, email etc which will get sent to me.
I have tried simplecart.js which does all of the clever add to cart stuff; I just have no idea on where to start in getting this data from simplecart into a form via Zem_contact_reborn.. If anyone here is a whizz with jquery, I’m sure it’s not impossible..
Any help from the clever people here (And I know there are loads because I use Textpattern and it’s a great bit of software) will be greatly appreciated.
Cheers
Offline
Re: [request] Add to wishlist / basket
carlahearne wrote:
Any help from the clever people here…
I don’t profess to be in that bracket, but I could offer a starting point based on the jQuery cookie plugin (see some examples). Assuming:
- you’re using HTML 5
- you have a bunch of items on the page and an ‘add to wish list’ link/button near each
- the link/buttons have a class of
add-to-wish-list
- you have added the item description to the
data-descript
attribute of your button/link when the page was built
this untested scrippet will append items to an array and store them.
jQuery(function() {
jQuery('.add-to-wish-list').click(function() {
var cookie_so_far = jQuery.makeArray($.cookie('wish_list')); // make cookie an array in case it isn't already
$.cookie('wish_list', cookie_so_far.push(jQuery(this).data('descript')) ); // append item to array
});
});
It might be necessary to serialize the info or use JSON to encode it or something (I’m not sure of the limitations of storing arrays as cookie values: javascript might handle it natively or do the necessary conversions on your behalf: someone else will be able to advise).
Then, assuming you have said array of clicked on items (or your simplecart object), your zem_contact_reborn code on your “checkout” page might be made up of:
<txp:zem_contact to="admin@site.com">
<txp:zem_contact_email />
<txp:zem_contact_text label="Phone" min=7 max=15 />
<txp:zem_contact_textarea label="Wish list" name="wishlist" />
<txp:zem_contact_submit label="Send" />
</txp:zem_contact>
That textarea will be empty so you’ll need something like this to populate it on page load:
jQuery(function() {
var contents = '';
// Add each cookie item to the contents variable
jQuery.each($.cookie('wish_list'), function() {
contents += jQuery(this).val() + "\n"; // or append '<br />'? Not sure
});
jQuery("textarea[name='wishlist']").val(contents);
});
As I say, totally untested, just off the top of my head so it might be gibberish; I’m sure someone will be able to improve on this. If you want to use the simplecart output instead of the array I made up, consult the documentation for simplecart to see how you can get access to the cookie object it creates.
You also may want to consider what happens if they click the same ‘add’ link a few times (e.g. do you only accept one of each item or allow multiples) and also how to remove items from the wish list, but I hope it helps and gives you a jump off point.
Last edited by Bloke (2012-09-18 13:14:22)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: [request] Add to wishlist / basket
sessionStorage may be an alternative to cookies, it is widely supported now and does not require a jQuery plugin.
Offline
Re: [request] Add to wishlist / basket
etc wrote:
sessionStorage may be an alternative to cookies
Woah! That makes it a truckload easier. Nice one. note to self: stay abreast of HTML 5
@carlahearne: forget my crappy cookie code above and use sessionStorage instead if you are using HTML 5.
Last edited by Bloke (2012-09-18 14:40:55)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: [request] Add to wishlist / basket
It looks like I need to do a bit of reading on session storage; I plan to use HTML5, so it should work a treat..
I’m still trying to get simplecart working too; it seems like a snice solution; I’m just stuck at the last hurdle… If anyone any good at jquery, could you possibly message me / email me for a bit of help?
I’ll keep everyone updated as to where I’m at…
Offline