Hi All, I am trying to make a plug-in for the first time ever, so forgive my noobness.
All I want is a simple shopping cart.
To do this I need the post information from a form that will contain the amount if items needing to be placed in the cart, and the {entry_id} of the weblog I use for the products. I will probably need more, but if I can get this done the rest should be quite well doable for me.
Here I have a simple test webshop:
And it’s made like this:
{exp:weblog:entries weblog="producten"}
<div class="product_container">
<div class="product">
<h1>{title}</h1>
{desc}
</div>
<div class="controls">
€{price}
<form method="POST" name="cart">
<input name="{title}" type="text" maxlength="2" size="4" value="0" />
<input type="submit" value="Place" />
</form>
</div>
<div class="clearfloat"></div>
</div>
{/exp:weblog:entries}
{exp:shoppingcart}information{/exp:shoppingcart}
What I have now is the post information that gets inserted between the shoppingcart tags. Later on it should function like a button that takes you to the cart.
This plugin is done like this:
class Shoppingcart
{
var $return_data = "";
function Shoppingcart()
{
global $IN;
foreach ($_POST as $key => $value)
{
$$key = $IN->clean_input_data($value);
}
$this->return_data = $$key;
}
Is it possible to store the information I need in a session in a array, so I can show the items on the shopping cart page? And is this a good way to do this or should I approach this differently?
Thanks!
All definitely possible and is in fact exactly what I have already done in a plugin that I made for a site a while back 😉
You can see it in operation over here if you like - http://www.flyheli.co.uk/cart/category/C45/ I used session variables to store the information that was needed and then placed a lot of code in to allow the information to be spat out wherever, whenever and however the end user likes so that they get complete and utter layout control.
Just to say that my plugin is my first and so far only commercial product and quite a lot of users on the forums have now purchased it so I wouldn’t obviously want to give away too much of what I did as that would do me out of potential earnings but just to let you know that yes you would probably want to store the entry_ids in an array and then use those from within the standard weblog tags or whatever.
Best wishes,
Mark
Lol, that is exacly what I want. Where can I buy it? 😊
If you want to PM me then I can tell you more about it on there. I am just about to leave work and so will be back home in around an hour or less so will be able to answer you there then.
Speak to you soon.
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.