Add Percentage of Sub-Total Field to Shopping Cart Page

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 year ago
Working with:
  - no-source nopCommerce 4.50.1
  - restaurant ordering

Issue:
  - unable to add Checkout Attribute(s) that either (1) calculates a percentage of the Sub-Total or (2) allows the customer to add their own amount and then add that as a Tip to the Total

(1) It appears this is not available out of the box. Is this correct? If not, what's needed to add this?

(2) In any case, it's time to jump in and learn coding in nopCommerce, starting with this. I downloaded the source code for nopCommerce 4.50.1, installed VS - Community, and opened nopCommerce successfully in VS. Where should I begin? For example, what would I need to adjust to add the new Checkout Attributes described above?
1 year ago
To jumpstart custom development, as you need to work on the product attribute you may try understanding the product attribute workings first, I mean set up different attribute with combinations and try to learn how they work for your different use cases.  
Then try to understand  Product,ProductAttribute,ProductAttributeMapping DB tables relations first.
Then go to the src/Presentation/Nop.Web/Controllers/ProductController and navigate to Product details page region and expand it. Go through the ProductDetails action method and try to understand it, It's basically the starting point where your products information related to price/attributes/pictures etc. gets prepared for viewing.  
You'll find the PrepareProductDetailsModelAsync method gets called here, This is the actual factory method which prepares your product data also attributes.  Inside this method, another factory method named PrepareProductAttributeModelsAsync gets called which prepares the product attribute related informations and this is your sweet spot.
You'll find several service methods gets called here to find the attribute mappings and combinations for product, the price adjustment for attributes and etc. Basically all you need to have these customized if you want to extend the default logics.
1 year ago
Hi,
(1) Yes, it is not available out of the box.
(2) I would recommend you not to modify default nop checkout attribute behavior.
Instead of that, build a plugin which will add customer enter price type product as a cart item.
To do this, when customer is on cart page, add a default widget portion which will show popup/regular input box to ask about the donation amount. Then handle this input value in the plugin and add a cart item using that value.
Follow this solution, only if you are okay about an additional cart item for donation. Also it will be a bit complex too as you are new in nopCommerce. But you can determine the tips amount easily in this approach!
1 year ago
Here is a partial solution using no-source:

(1) Add a dropdown list Checkout Attribute that has the percentage values in arithmetic sequence with corresponding Price Adjustments:
    - Example: 0.00, 0.25, 0.50, 0.75, 1.00, ...
(2) Using jQuery:
    - Calculate the exact percentage desired
    - Determine the least value in the dropdown list that is greater than or equal to this
    - Select the corresponding <option> in the dropdown list

Issues:
    - There will be a maximum value (MAX)
    - Only values in the list may be selected
        - Theoretically, all values between 0 and the MAX, with 0.01 increments, could be included
        - If done, jQuery could be written to allow a number-only text field that links to the dropdown list
    - Price Adjustment redundantly repeats the amount
1 year ago
@MarkHS
Since your site is for a restaurant, I wonder what it is you are doing with the Shipping method selection page.  Did you disable it?  Maybe you can use that to accept the Tip amount.  (You can 'calculate multiple 'methods' with amounts 10%, 15%, etc.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.