Express Checkout Customization in Hybris - sap-commerce-cloud

Suppose a user has 2 items in his cart. He goes to another item detail page and clicks buy now. Now, by default, all the two products also add up and go for checkout. My requirement is that when the user clicks buy now, then only that product should proceed and not merge with the other two items in the cart. If the user does not complete the order placement procedure, then it should be added to the cart with the other 2 items. But if he completes the order placement procedure, the other 2 items should stay in the cart.
This is what Flipkart does. Any suggestions in how to achieve this?

Usually, such tasks require a big amount of analytics to find all cases. But a simple plan is:
Create a new button for "Buy now" that will call your own controller/facade/service instead of de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartService#addToCart
Add a new boolean property buyNow to the CartModel
Your new service needs to clean the session from the previous cart. Create a new one with cart.buyNow = true
redirect your customer directly to the checkout
If a customer leaves the checkout or successfully places an order. Clean up all his carts with the buyNow flag. And run a cart restoration process that will return his original cart.

Related

Shopware cart.updated_at changes on login

As a logged customer , I've added some products in my cart (new entry in cart table is inserted with all my data)
What I observed: Every time I login to my account, the cart.updated_at date field is updated even if I'm not changing anything to my cart.
Is this a bug? If not, why does that field need to be updated every time we login?
Tested on shopware 6.4.14.0 and 6.4.11.0
The field is updated on every action I take as a logged user
There's a CleanupCartTask that removes abandoned carts that haven't been updated for a certain amount of days (120 by default, configured in shopware.yml). For this task alone the date needs to be updated, otherwise abandoned carts couldn't be identified.
Furthermore the cart needs to be recalculated because rules that influence prices may have changed or been added. This alone doesn't necessitate persisting the cart, as prior and current active rules could be compared, but in conjunction with the aforementioned cleanup task, it's reasonable to persist the recalculated cart anyways for safekeeping.

User event Before Submit doesn't work in case of automatic PO creation (NETSUITE)

Is it possible to restrict the purchase order created automatically like when any dropship or special offer item selected in sales order?
I can confirm as of very recent discussions and testing with Netsuite that before submit does not trigger on automatically generated purchase orders.
We have an approvals system in place and were hoping purchase orders could be auto generated and stay pending supervisor approval but this is not possible as the before submit does not trigger.
An enhancement request has been raised by Netsuite for this functionality.
The behaviour of dropship and special order items is dependent on a checkbox. If you clear the checkbox when the order is approved then the automatic POs will not be created.
Checkbox clearing may be done by the user or may be done via a Before Submit user event script on the Sales Order.
If the need to restrict PO creation has something to do with PO vendor characteristics where you may also need to restrict general PO creation then you should extract the vendor check to a library file. that way it could be used in the SO beforeSubmit to clear the createpo flag and the PO beforeSubmit to throw an error.
You could also use the PO After Submit "specialorder" or "dropship" events to check the PO vendor after submit and delete the created PO.
However given your explanation in the comments the SO shouldn't be able to be approved. i.e. why take a drop ship order where the components are not orderable?

Opencart (Cart page ) Update price when change quantity Automatic

I am making the Review Cart & Checkout form. If users want to change the quantity I want that if quantity is changed the price of it will be changed automatically.
Please help to adjust the code in the same JS of plus-minus or separate.
In OpenCart cart is updated by submitting data to server and then getting response. This is done because product information is in encrypted form and every time needs to be submitted to server. So only Js in client side is not sufficient. So you can use following points.
`These steps can solve your problem.
Create your JavaScript functions which decreases or increase number in quantity box.
Do not remove your update cart button in original cart page.
Make use of that button to update your cart.

NetSuite, prevent Quote to Sales Order (via Sales Order button) if prospect assigned vs customer

We allow sales to attach Prospects to an Opportunity and Quote, and once credit has qualified the prospect they promote the prospect to a customer. What we need to do is hide the "Sales Order" button on the quote, or disallow advancing the quote to a sales order.
I was hesitant to ask this- seems like it should be intuitive to figure out. I looked at the standard NetSuite button id's in NetSuite help but there wasn't one for "Sales Order". I've looked at validation logic but this isn't validation as the sales order button is shown when record is not in edit mode. If possible I'd like the solution to be form independent.
I'd be happy to hide the button or letting the user click the button and preventing them from creating the sales order. It might be more user friendly doing the latter because if the button is hidden sales will be calling asking why the button is not there.
For clarity here is an image:
I am assuming that when you are talking about "the Sales Order button", you mean this one:
I'm not sure if this is the best user experience, or if you have NetSuite development resources available to you, but here is one option:
Create a new User Event script that is deployed to the Sales Order (and any other Transaction record you may want this prevention on). Using the BeforeLoad event, you can check if the Entity on the Transaction is in the Prospect stage. If they are, then the script will throw an error, preventing the creation of the Transaction. Code to accomplish this:
function onBeforeLoad(type) {
var entityId = nlapiGetFieldValue('entity');
if ((type != 'create') || !entityId) { return; }
if(nlapiLookupField('customer', nlapiGetFieldValue('entity'), 'stage') === 'PROSPECT') {
throw nlapiCreateError('INVALID_REQUEST', 'You cannot create a Sales Order from a Quote placed for a Prospect');
}
}
I tested this code in a TSTDRV account, and it works as expected. You might alternatively be able to build a workflow that does the same thing without requiring you to write code, but I did not attempt this.
By using a User Event script, this code will be form independent as well as entry point independent, meaning that this code will execute if the Sales Order is being created through the UI, through some other script, through a web services integration (depending on your web services configuration), or through a CSV import (depending on your CSV import configuration).
To hide the option:
If you're referring to the dropdown list, you can create a script for context view/edit to do the following:
setFieldAndLabelVisibility("nl13", false);
Otherwise, replace nl13 with the value of the table or td element shown when you inspect element on the desired Sales Order link/icon.
--The ID in the example above is the table, button or label ID shown when you inspect element

Generating a PayPal payment link for a product and using it as a menu link

I hope to create an accordion menu that follows as a user moves down the page. I would create a separate menu with each item being a link item for a menu. Can I generate a simple link for an item that costs $39, another item that costs $79 and so forth? I am selling a small number of services and simply need to generate a link that goes to a specific item (one of 4-6 menu items, for example) at PayPal and allows for payment. I was trying to do something other than payment buttons becuase I want users to be able to make a purchase from nearly anywhere on my site.
Take a look at these 2 resources, they should be able to get you close to what you want.
1) https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/buynow_buttons/
2) http://www.wikihow.com/Make-a-Paypal-Payment-Link

Resources