What steps should the add to cart operation go through? - asp.net-core

I am planning to make an e-commerce site and there are some steps that I need to think about.
For example, I will add a product to the cart. In your opinion, what stages should this process go through in the background in order for me to take this action? Which checks should be done in what order? For example, if I assume that I will do stock control, should I do this stock control through a separate stock microservice? Other than that, what kind of steps and checks should it go through?
Here's what I'm planning. I have a frontend application and from here I will send a request to my cart service (a rest api) via an ApiGateway when the user presses the add to cart button. The addbasket method of this service will be run. Here I will first check stock from my stock micro service. If there is stock, I will add it to the cart. If not, I'll be back.
What else should I do here? Also where should I store the basket? Should I consider a database or a different option?
Actually, what I want to ask is what steps should I go through and what controls should I do to develop the add to cart operation. At this stage, where should I store the products in the basket, etc.?
Could you please explain what is the best way to make this work?
thank you everyone

Related

Shopify: custom scripts in the checkout to execute web requests

I've a client that wants certain clients to buy with Store Credit. The amount of credit is stored in their external ERP system. My idea was to create a manual custom payment, show this payment method for users with a certain customer tag and add some scripts in the checkout in order to execute a web request and get how much credit the client has at that moment and do some validations (don't let them order if the checkout is bigger than the credit) in order to let them complete the order or not.
The only link I've found basically says:
With a few exceptions, Shopify Scripts are not capable of input/output. This means that scripts can't execute web requests or database calls, and can't get input from a user. Source: https://help.shopify.com/en/manual/checkout-settings/script-editor/limitations#input-output
The client is aware they need to upgrade to Shopify Plus, but I can't find examples or any information that indicates this idea is doable.
I don't think Shopify Script is the solution in this case. (You can't make any outside call inside a script)
If you plan to use Shopify Plus you can modify checkout.liquid. You can create an app that has an endpoints that
Tells you how many points the customer has
Redeems X points and returns a discount code
Having that you can put a javascript that when checking out insert a button to redeem the points and if it's clicked you call the api and apply the discount.
To apply dynamically a coupon at checkout this is a working piece of code.
document.querySelector("#checkout_reduction_code").value = YOUR_CODE;
document.querySelector(".field__input-btn.btn").disabled = false;
document.querySelector(".field__input-btn.btn").click();
Other solution is to use Shopify Functions (https://shopify.dev/api/functions). This is a new feature that is availble in preview and lets you customize the checkout experience. I don't have experience with that but I suppose you can do something similar.

BigCommerce Custom Add To Cart Speed Issue

We had a developer add a custom code to certain product pages so that the user could order multiple quantities of multiple product variants all at once from one product page.
The issue is that the script takes too long to run...when you click Add To Cart it is taking 30-60 seconds or more to add all the products to the cart.
That is way too long. (see video here https://www.dipietro.biz/wp-content/uploads/2017/04/add-to-cart-slow.webm )
This is because the script is adding each product to the cart sequentially one by one instead of simultaneously.
Is this something that can be fixed?
We need the Add To Cart speed increased drastically.
I've been told that if we had access to the cart.php file that sits on BigCommerce's server we could just add some type of ajax multi array function and that would solve the problem but of course we do not have access to BigCommerce's servers.
Any help is appreciated at this point.
Thanks!
Without seeing the code, most likely the issue is that, as you mentioned, the products are being added to the cart sequentially, while also waiting for each individual add to cart request to finish before beginning the next - that is, it will add a product to the cart, wait for that product to successfully be added, and then proceed to add the next product to the cart.
Each 'add to cart' action is an individual POST request to the cart.php file. There is a challenge here in that BigCommerce will block the requests if too many of them occur within a certain time period; this is a BigCommerce security feature.
While you do not have access to the cart.php file, and while I do not know the specifics of the BigCommerce rate-limit/security feature, the best way to approach this is to determine and set a feasible max number of concurrent requests as well as a necessary cool-down period in order to maximize the number of requests to BigCommerce while also satisfying the security/rate-limit limitation.
For example, you might set up the program to concurrently add 3 products to the cart, wait 1 second, and then proceed to add another 3 products. Does this make sense?

How do I access Shopify data without advanced account?

All I'm wanting to do is track sales of certain products from a certain date. My company is wanting to add a banner to track sales goals for raising money for charities. So basically, we'd tag a few products as being part of that goal, set a goal, and then need to update the goal progress by a certain amount every time a sale is made on one of those products. As far as I can tell, without access to Shopify's analytics API, this is not possible. How can I do this?
What you want to build is perfectly possible. However, you need to generate Private App Credentials, so you can use Shopify API. It doesn't matter if you have an account by yourself, someone else can follow these steps and send you the credentials your way.
If you don't actually need to modify anything through the API, you could have them set a webhook (Settings -> Notifications -> Webhook) on Order Creation (or similar) that posts to your server and you can check what product got sold and see if it has got the tag.
The "easy" way to do this is to create an app that receives order webhooks and can check on tagged products and keep a sum of target items sold.
Then the app should have use a script tag to insert a simple script with the current value into the web page at a configured place by css selector
OR the app could update one or more snippet files that you could include until the promo is done.
I'd tend to go with the script tag option since that's a bit more flexible and you should be able to change your theme when the promo is over to report results without having to touch the app again.

How to get list carts with magento API?

I working on Magento with carts. I using SOAP to create cart and add products to it. but can i get list of carts. And how to active it.
In dashboard of magento admin, i see
Reports > Shopping Cart > Abandoned Carts
with list of carts is active. Can i get it?
Thank a lot, sorry for my bad english.
If you want to see how the query behind the report is generated, have a look at https://github.com/magento/magento2/blob/83132783e0a6bed32c45e6d06df851865e668abc/app/code/Magento/Reports/Model/Resource/Quote/Collection.php#L54 - this is the code that forms the query. You can see the table fields it uses (e.g. checking if is_active, must be at least one item in cart, etc), then sorts by updated_at so oldest cart comes up first.
There is also a blog post at http://cyrillschumacher.com/2015/01/02/magento2---search-parameters-for-the-rest-api/ which describes (for the REST API) how to build a search. It is backed by the same data constructs as for SOAP.
You can use the end point http:///soap/default?wsdl&services=quoteCartRepositoryV1 to bring up the WSDL file.
Sorry, I don't have time right now to build up the SOAP request myself, but hopefully these pointers are useful to help you make some progress.

Easiest way to sell stuff and track inventory

on my website I sell unique items. I have programmed it so that on the selling page, users can select any amount of these items, and it calculates the cost. The key is that I only have 1 of each of these items. So I need the shopping cart system to not allow the payment to go through unless it is available.
I've been searching for a good quick/easy/cheap solution and can't find one. I don't expect this site to make a lot of money (the transactions are a few bucks), so I didn't want to need a ssl certificate.
The only way I know of not needing an ssl certificate would be to use paypal or google checkout. However, I do not think there is a way of using these services and making paypal's server run a script to check how many are available on the site. Any solution?
Thanks
I was thinking about it more, and I think the problem is that once the user gets to the paypal payment screen, I have no control. I guess I could do something like they click the buy it now link, a php script updates it to sold, then they go to the paypal screen, but then they might not continue the purchase...
If you use PayPal Website Payments Standard (using a cart rather than 'Buy Now' Buttons) then you could use IPN or PDT (see the paypal docs here) to get PayPal to call back to you with the status of the payment.
The work flow would then be to set status to reserved when the item is added to the cart, and then wait for the IPN/PDT call to come back with the payment status, and mark the item as sold.
You would still need to check and reset to available any item that had been reserved for longer than say 2 Hours. (You could do this before serving a page to a user so that they have the latest availability and you don't need a cron job or long running process)
If you could provide a little more information about how you have implemented ur shopping card, it would have been more easier for other to assist! If you are using any ecommerce solution then it should be there already in the track inventory section. But Provided that you have implemented d shopping cart manually, why don't you add little bit of codes that checks the inventory status first before letting your customers check out?