Adding eCommerce to a Wappler Site

Since there doesn’t appear to be any way to build a shopping cart and integrate it with Paypal in Wappler, if I build a site in Wappler and then take it into DW to use the Sliding Paypal extension will I run into issues?

I have a site that I need to rebuild soon and I’d really like to use Wappler. Going back to DW is painful now.

I too have been wondering how best to approach the need for adding a shopping cart in Wappler… The last shopping cart I used was eCart from Webassit in DW. I do not want to go back to using DW. I’d really like to port everything over to Wappler. Anyone know of a solution or a timeline to one?

Well just a simple shopping cart you can do yourself pretty easy with the App Connect and State Manager.
I think @Teodor has a step by step guide somewhere.

1 Like

But not tie it in with any provider like PayPal though, if it is the guide I remember seeing.

Indeed as one wants PayPal another Stripe - many possibilities out there

That’s right. So make it happen! :wink:

Will do :slight_smile: - we were already looking for building more close integration with Stripe - because they are the best :slight_smile:

Something like Stripe Connector - having both front-end side (App Connect components) and also back-end side (Server Connect) for handling the stripe hooks for full blown integration.

5 Likes

I am creating an ecart with AppConnect and it is not that difficut. I am using a table to set the items in the cart, a cookie value to remember the user who is adding the items in the cart. Once you have this set it is super easy is to create the add | update | delete to cart. I had a chat with Teo a few months ago about this but can’t find our conversation. If I find it I will post it here.

I thought I remembered something too but can’t find it. How are you adding the cart totals to a credit card processor such as PayPal?

Havent reached to the step to integrate paypal yet… Regarding the cart itself give me a minute please

Don’t know if it is something you need, I mean you might have already implemented it. This is how add a product into the cart

<button dmx-on:click="cookies1.set('mc_cart','<?php echo $cook;?>',{expires: 30})" type="submit" class="btn icon-btn-md btn-theme icon-btn-round lh-1"  dmx-show="!cookies1.data.mc_cart"><i class="ei ei-shopping-basket">CookieME</i></button>
<button type="submit" dmx-hide="!cookies1.data.mc_cart" class="btn icon-btn-md btn-theme icon-btn-round lh-1"><i class="ei ei-shopping-basket"></i></button>

I am using two buttons. One is showed when no cookie is set. When clicked it creates the cookie and adds the product.

Second button is showing when cookie is already set and it only adds the product to cart using the same cookie value

Again don’t know if this is the information you need. If yes can describe more.

Thank you

Thanks @George. Hey @Teodor, any chance of getting a link to that tutorial?

Hey Armen,
I am afraid no such a tutorial is available - just a couple of guideline posts in DMXzone forums.
I will try to setup a step by step guide in the how to section about creating a shopping cart, storing the users session IDs in a cookie and filtering the database table using it.

2 Likes

Hi Teodor

I think this would be very useful - not just to demonstrate an extremely common website feature (a shopping cart), but I would imagine it would also cover several techniques which may be puzzling to someone new to Wappler. It could be a very good example to show off Wappler’s power.

I had decided there were too many features missing - at least from the DMX extensions - to create a shopping cart, and decided it was simpler just to use PHP. I would prefer to use Wappler if possible.

The main problem was the it seemed not to be possible to use sessions or cookies to store the cart information. I don’t know if this possible in Wappler. I see ‘Add Array’ and ‘Add Object’ options in Wappler - do these work? I would really appreciate some information on adding/removing elements to/from sessions/cookies if it’s now possible. When we discussed this some time ago, you suggested using a database table as an alternative.

The other problem was that it didn’t seem possible to send order confirmation emails etc. - because dynamic content can’t be included using the mail feature (I think this is still the case in Wappler). If you can suggest an alternative approach, that would be very helpful (or perhaps this extension will be improved). I realise this is not directly related to shopping carts but it’s something someone developing one will probably need - and might be surprised to discover wasn’t possible (if it’s not).

Hi, it is possible to sotre cart details using a cookie value. I am already building a shopping cart using AppConnect. My issue is that I am still working on it and can not send link to this website.

Okay i will try to explain the logic here, so you can get the idea.

First you need a session cookie and a session which we use to identify the users (no matter if they are logged in or not).
This can be done using the following code, placed on top of your page:

<?php
	session_set_cookie_params(86400,"/");
	session_start();
	$randNumber = mt_rand();
	if(!isset($_SESSION['cart_session'])) {
			$_SESSION['cart_session'] = + $randNumber;
	}
?>

What this code does is to set a session cookie for 86400 seconds - i.e. it will keep the cookie for 1 day. Change this to whatever you like it to be. This is what keeps the products in the cart when the users enter the site after a certain amount of time.
Then it sets a session called “cart_session” which gets a random (unique value) for each user.

Then you define this session under globals in every server action related to the cart - in add, update, delete actions and in the cart contents action:
Screenshot_36

Create a table which stores cart content. It will store the content for all the users carts. Then we filter it by this cart_session value.

So in add products to cart server action you insert the product ID and use cart_session in the database:
Screenshot_37

And when displaying the cart content you use the same cart_session for the cart content action to filter the cart content table.

Same for update and delete actions - filter by the cart_session value. Then on successful checkout, you just remove everything related to this cart_session value from the cart content table.

These are the basics required for basic shopping cart functionality. Of course, you can extend it to check if a product exists in the cart content table for this user on add product - run database update instead of insert.

You can extend it to use coupon codes etc. but for basic shopping cart/wish list functionality the above is functioning perfectly.

5 Likes

Thanks Teodor - this looks really helpful.

I think the interest in this topic shows there is a need for some sort of eCommerce Extension in Wappler sooner rather than later.

2 Likes

I am following your demo but am lost as to how you got form the cart_session under &_SESSION to the table columns shown below it.

52%20PM

You must define it under globals.
Then you use it to filter the query.