Programmatically create order in shopware plugin - shopware

I need to create ShopWare 6 plugin that creates new orders from products that are received via AJAX POST request. I don't know how to do that. I googled and checked documentation but I couldn't find any info on how can it be done.
Does someone know how can it be done?

In my opinion, the best solution would be to create Cart object from products that you get from request probably you know context token so you can use the current customer's cart and add products to it, but also you can create a new cart and then call \Shopware\Core\Checkout\Cart\Order\OrderPersister::persist() method to persist order from your cart.
Take a look here how to load/create a Cart
\Shopware\Core\Checkout\Cart\SalesChannel\CartLoadRoute::load()

Related

Automatically updating Shopify inventory item quantity

I have a Shopify store with rental products. Since Shopify doesn't handle return flows, the shop is connected to an external service, were the order is sent via an API to that service, which handles finalizing the rental and tracking it.
Now here is the problem, since the procedure is finalized outside of Shopify, the products are removed when rented, but not added when returned. this makes updating the shop manual. I am currently using Pipedream to handle my Web-hooks and requests, and it provides a service to change Inventory Level, but no direct way to update Shopify inventory. I know that the only way to update quantity in by getting InventoryItemID, and the only way to get that is by using ProductVarientID. I was able to acheive that using GraphQL, but I'd have to manually quary the InventoryItemID by using the ProductVarientIDs of my return orders from an API, and then use a mutation that does bulk inventory update to get the job done, but you can see, this is hardly automated.
Any thoughts and ideas are much appreciated.
If there is a way to do it using Pipedream, that's super.

What is the best way to create cart in nodejs,expressjs with hbs?

My question meaning is that what should we use to create cart in e-commerce site in nodejs. Should we direct add the data in mongodb or first use to create session from collected items. What should we do. If the session is the best way to create cart then please suggest me a best way to create cart in sessions thanks
Creating an entry in db would be great because you may need to access user cart at any point of time so instead of managing session, managing db would be good idea.
one more suggestion I would like to give is that when user is checking out the cart then before checkout validate the cart.
suppose, user has added any product to the cart and then does not checkout the cart but after some days, user is checking out the cart and the product in the user cart is out of stock then you need to remove that product from user cart or may be the price of that product is changed then also you need to notify user for this before checkout. This type of validations are included in validate cart.
Hope this helps!
Thank you

Update custom fields on Paypal

I use the NVP integration on Paypal and I'm facing a situation that I need to create a method to update some info on an already placed Paypal order. The only field that I need to update (edit) is PAYMENTREQUEST_0_CUSTOM, but looking on the docs I couldn't find any put/patch methods that would help me here.
Anyone has any inputs on this case? Have anyone ever update info on placed orders on Paypal?
Thanks in advance!
There is no method to patch the information of an already completed PayPal sale transaction. Once such a transaction has completed, it is final.
If using paymentaction=order or paymentaction=authorization, you can update information when doing the DoCapture which is the final step to create a transaction. This final step can fail, so do not change your integration to paymentaction=order or paymentaction=authorization unless you have very specific business needs for those features.

How cart and checkout internally works in Hybris?

Can anyone explain how cart and checkout work internally?
means when you click on ADD to cart button what exactly will happen?
It's not possible to explain everything here, better you ask with the specific problem. Refer how do I ask a good question?
Now coming to your question
When you click on ADD to cart button what exactly will happen?
An add to cart form is submitted through ajax call(.ajaxForm), you can find the code inside acc.product.js. This invokes addToCart method of AddToCartController, as /cart/add request mapped with it. Furthur this controller invoke facads to add selected product to cart and return AddToCartPopup.jsp as JSON response, which help to render AddToCartPopup on the screen.
You can start firstly to read pages which are on helphybris.
Small Explanation :
Cart & Checkout (formerly called Order Management Module) is a set of services that enable you to define your own business process steps such as: authorize payment, capture payment, and cancellation.
Cart & Checkout is a template business process definition for you to extend and integrate with Order Management Services or 3rd party Order Management Systems.
If you have a access
: https://help.hybris.com/6.7.0/hcd/8c20e24d86691014ba61d588779202ae.html
Another way is making debug. You can put a break point to AddToCartController for debugging to press "add to bag" button on frontend .

Controller-based Associations/Relations in SailsJS

Say I have a ShoppingCart model with a one-to-many relation to an Item model (i.e. A shopping cart can be full of different items).
I can obviously create a new shopping cart like so:
POST /api/shoppingcart
What I'd like to create is a RESTful API where an item can be added (or updated) to that shopping cart like this:
POST /api/shoppingcart/:shoppingCartId/item
PUT /api/shoppingcart/:shoppingCartId/item/:itemId
From the research I've done so far this doesn't seem built-in to SailsJS. I'd prefer to stay away from manually setting these routes. Is there a way I can automate the route with the ShoppingCartController?
Never mind, found out Sails does it as long as you have the config rest option enabled.
It works with GET, POST, and DELETE methods.
[parentModel]/:parentid/[childModel]/:id?
Check the source: https://github.com/balderdashy/sails/blob/master/lib/hooks/blueprints/index.js#L319

Resources