Assign an order to a customer service rep in VirtoCommerce - virtocommerce

I'd like to assign each order to a customer service rep (CSR). That CSR will then be responsible to confirm any payment details, oversee shipment and answer any questions from the customer. Questions:
How do I do that in VirtoCommerce?
Is there a way to do that automatically?
Is there a way for CSR to see orders assigned just to
him personally?

CustomerOrder domain model has a properties EmployeeId and EmployeeName you may use it to store information about order responsible.
VC expose multiple extension points and one of them is a Events http://docs.virtocommerce.com/display/vc2devguide/Extending+using+events. In you custom module you should subscribe to OrderChange event
//Subscribe to cart changes. Register in avalara SalesInvoice transaction
_container.RegisterType<IObserver<OrderChangeEvent>, OrderTaxAdjustmentObserver>("PlacedOrderObserver");
And inside you event handler implement order responsible assignment logic.
To implement auto-assignment functionality you should create new
module (any of VС extension should be only in custom modules to
preventing merging hell on updates)
Concerning to assigned to UI and filtration we added issue in github https://github.com/VirtoCommerce/vc-platform/issues/559 because it is the overall order functionality and it should included in Order.Module and should be realized our team.

Related

Extend Spartacus NGRX Store with additional data

For our Spartacus project, we need to introduce additional Data properties in the checkout:
We have the case, that the user needs to select a delivery mode per product.
In an ideal world, upon selection, the selected delivery mode would be saved in the NGRX Store and also in the Backend to stay within the principle of the data binding defined here: https://sap.github.io/spartacus-docs/connecting-to-other-systems/#component-data-binding
Expected Data / User flow:
User goes to Checkout and to Delivery Mode Step
Custom OCC Call is made to load the supported delivery modes for each product (depends on product type and further customer specific logic)
The cart items are displayed, enhanced with a dropdown containing the available delivery modes
The user selects a delivery mode
The selected delivery mode is stored on the cart entry within the NGRX Store and saved in the backend
The new Cart totals is calculated based on the costs of the selected delivery mode
The new Cart totals is stored on the cart within the NGRX Store and saved in the backend
The user clicks on continue to get to the Review Order Step
The cart items are listed with the previously selected delivery mode
After some analysis of the existing code, we found a property deliveryMode on the orderEntry. This does not seem to be used anywhere in spartacus, but could be used to make Step 9 work by following this stackoverflow answer and this one.
Questions regarding this flow:
How can we extend the NGRX Store? We assume, it would be possible to just extend the facade (Active Cart Service), bypass the store and save the information in the backend (Described here) and afterwards refresh the store from the backend. Is that Assumption correct? If yes, that feels awkward though, as we need to reload the whole store just to contain the new property deliveryMode on the orderEntry
How can we hook into the price calculation of the cart totals to update the total based on the selected delivery mode? And again, how can we bring the new total sum into the store?
There seem to be several Answers within the Slack Channel without very few usable answers around extending the ngrx store, even though for us, it seems to be a quit normal task.. :-/
Any thoughts, inputs or support would be very appreciated. :-)
This seems like a difficult thing to accomplish seeing as delivery modes per product aren't supported as-is in spartacus. But some ideas:
You can extend core CartEntry classes (adapter, connecter, facade, etc.) to include the delivery mode for entries added to the cart. You will probably need to change all to include the delivery mode setting(s). All of these are exposed so you can modify them as needed including the store.
Utilizing multiple carts to have a product per cart and set delivery mode that way. But this would be cumbersome in my opinion.
As far as price calculation goes, I'm assuming OCC calls return total prices. Does the call for the cart entries include delivery mode costs per entry?
We have implemented the following work around and it works so far:
Enhance the Cart Model in the backend
Add new Endpoints to load the available delivery Modes per Product (by bypassing the NGRX Store)
Add new Endpoints to save the selected Delivery Mode (by bypassing the NGRX Store)
After Save Endpoint, a cart Reload is triggered, which loads the new cart totals having a custom property on the order entry (via type augmentation) into the store from the backend
It's already a lot of years past since Spartacus project started, but looks like it's still really raw projects. Spartacus is not ready to deal with real word customer's requirement and complexity of customize it quickly grow at real project(so you start to think do we really need it, as it's so unflexible at some dimentions). Some parts is really hard or not possible to customize, so you begin to search a workarounds(This question is one common case).
I think NGRX Store is one of the biggest pain in the ass to customize something at Spartacus. 2 years past and nothing changed by Spartacus team...

How can I implement modifiable products (which are subscriptions) in Shopify?

I've implemented subscriptions through ReCharge where users can select products and these are saved as line item properties for that product. This was the only solution I could think of with my limited time using Shopify.
Per this question, it seems like line item properties are read-only after checkout. If this is truly the case, is there any solution that enables having modifiable subscriptions where users can re-select products for that subscription product that I can implement?
I'm using Shipstation for the shipping piece if this matters at all.
How can I implement modifiable products (which are subscriptions) in Shopify?
You can't. Well, technically you can but it is not easily done. Since you indicated that you're looking for official answers, I've contacted Shopify via email for you and I've been discussed this with Brad Leclerc, where he said:
That is indeed the case with line item properties being read-only after checkout, so it would need to be reconstructed for the new order. There's no super quick/easy to do that without some custom development to automate the process. If you end up wanting to do that, I'm sure a developer from http://experts.shopify.com could set something like that up.
You have two choices, either hire someone from experts.shopify.com to help or build your own marketing script from scratch.
Proof of email: http://i.imgur.com/OeM5gSm.png
I'd do this with meta fields on the customer.
meta fields can be used on the subscription product template to make it sensitive to the state of the customer's subscription (new or existing)
Use a order web hook to detect when a new subscription product has been purchased and then update the customer meta fields (e.g. subscription level and start and end dates).
use a periodic task in your supporting private app to:
prompt user before subscription becomes due to update their payment details or cancel the subscription
create and bill new orders for each subscription period
I am not familiar with Shopify, nor Revcharge, but according to the references, couldn't you simply customize the product page in shopify?
https://docs.shopify.com/manual/configuration/store-customization/page-specific/product-page/get-customization-information-for-products
According RevCharge, you should use a Shopify product template anyway..
http://recharge.helpscoutdocs.com/article/91-recharge-integration-guide

VirtoCommerce - Creation of a new payment gateway

I have a big problem dealing with new payment gateway creation. I followed a tutorial but I think I did something wrong because it doesn't work well.
I would like to create a "devis" (sorry I don't know the word in english... It looks like that.
When the customer buys something, he could choose this kind of payment which does nothing but provide the "devis". It would be perfect if the status of the order could be "on hold" directly in order to unhold it when the "real payment" is done.
I hope you have understand what I try to do but if you have not be free to ask me questions.
Here is what I've done:
I created a new class in the VirtoCommerce.PaymentGateways namespace called DevisPaymentGateway which inherits from the PaymentGatewayBase class.
In this class there is just one method: ProcessPayment where I do:
payment.status = PaymentStatus.Completed.ToString();
in the SqlOrderDatabaseInitializer.cs
I created a private SetupDevisGateway method:
private void SetupPaypalGateway(List<PaymentGateway> gateways)
which is called in the CreatePaymentGateways method just after the paypal gateway.
I deployed the database thanks to your powershell script, the gateway
is created as expected.
I enabled the gateway payment via
VirtoCommerce Manager Then I bought something on the website and I
chose the new Payment which is available so it seems to work.
When I click on proceed to checkout I have a new order line which is created
with the "Pending" status so it's perfect...
When I bought something with paypal for example, there was the same reaction BUUUT when the new order line was created there was the onBeforeUpdate method which detected that new line and some work was done asynchronously. With the new gateway it seems that the onBeforeUpdate method doesn't work anymore...
I think that I've forgot something which is done with Paypal and not with my gateway but what and where?
I already know that it's not a good idea to write something in the SqlOrderDatabaseInitializer.cs but I don't think that it's the problem... Does anybody have a solution?
Thanks
Edit: Explanation on what I try to achieve:
Products which are sold are in fact a couple: "images treatments" + "images"
Each customer can manage album and put photos into it, and when he clicks on a product (which is a treatment) he can choose an album.
So it's why I need this event, when the payment is done and the status change from pending to in progress, I send relevant information (about the treatment, the album...) to a queue and I have worker roles (one for each treatment) which read these messages and do some work.
I hope you understand the idea but if you don't, do not hesitate to ask me questions
can you explain why do you need that event? What will you do when that event is raised?
Some explanation below on how status is changed for the order below:
The order status is actually changed by the job "ProcessOrderStatusWork class" that simply runs in the background and changes the status order status from "Pending" to "InProgress" after order has been in pending state for a certain period of time. I would suggesting for you to create a copy of "ProcessOrderStatusWork" class and create a new job (name it MyProcessOrderStatusWork class), that in addition to changing status also adds custom work for your payment. You can then register that Job and disable the one included with VC, so it is not duplicated (by adding it in the database,similar to how you did payment gateway).
It might work for PayPal, because it uses slightly different logic, as order created on call back from PayPal, thus executing in the same web process and event is raised.

Is there a way to tag or identify specific orders?

Using the webhook api to retrieve orders, I'm wondering if there's some way that the orders can be tagged in some form so I can attribute them to certain objects in a shopify app. The scenario is a client wishes to be able to attribute certain orders to different charities. Is there a way they can identify the orders as such?
One thing I can think of is the visitor chooses a "product" which simply dictates which charity they wish the order sale to be donated to, and I look for that product in the webhook. But i wonder if there's another way.
You could use a cart.note or cart.attributes. They allow you to store custom properties with your order.
If you need a per product attribute, you can use Line Item Properties.

Setting carrier per product

I'm working on a store that has two types of products: perishable food and general merchandise. The food must always be shipped overnight via FedEx, and the other merchandise must always be shipped via USPS. If somebody orders products from both categories, they must be shipped separately.
Do you know of an existing module or configuration settings that would allow for this?
If not, it sounds like a custom module would be the other solution. In this case, what is the best approach? I'm thinking it would be splitting the order into a multi-address shipment, using the same address for both but with different shipping methods. Unfortunately I'm not sure how to do this programatically, so any tutorials/samples/resources would be greatly appreciated.
Probably the sanest way to handle this would be to create two orders per product type, each shipping with a different carrier to the same address. This also IMO makes more sense from a stores tracking perspective as you can handle each independently from each other.
To get you on the right track(since Magento is especially cryptic in this part of itself) you should read the Inchoo programmatically create order in Magento post and by the same author Programatically create customer and order in Magento with full blown one page checkout.
Basically as I see this going is:
Get the customer order
Itinerate through each product inside the order and split it up in two arrays for each product type
Create a separate order for each product type and use the different shipping methods for each.
You will probably have to extend a some controllers OR do it the non-standard way and use helper functions for this, the hard parts will be integrating the payment/shipping modules inside your order process. Going this way will have you creating the full checkout process as the one page checkout Magento provides won't really work and is too much pain to get to work because of the way it uses AJAX.
Also another alternative is to hook in to Magento's pre-create order events and create the orders there using already defined order data split it up in two orders, but this is something I never heard or saw implemented at the moment so you'd have to do it "blindfolded" so to speak.
An easier approach would be to use a custom field that defines your product's shipping method, this way you just add that and don't care about custom orders. You just react with that, however tracking will become mostly impossible IMO.
Over-ride the Free Shipping module.
You can setup a sales rule that applies to certain products and makes them 'Free Shipping', leaving the other products to your chosen main shipment provider.
You will need to see how this works, however, the point is that Magento does have something built in to split an order into two shipping categories, albeit only a sales rule on free shipping. But you have source code...