Need to get the values for

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 anni tempo fa
Need help finding the following values from the OrderTotalCalculationService.cs class:
Specifically, I need to find:

1.  Order Shipping Method
2.  Ordered Items
3.  Order Shipping Address (The State in the United States)

I was able to obtain these values from the PdfService.cs, utilizing the following approach:

           
string shipMet = order.ShippingMethod;
var orderItems = _orderService.GetOrderItems(order.Id, vendorId: vendorId);

Address orderAddress(Order o) => _addressService.GetAddressById((o.PickupInStore ? o.PickupAddressId : o.ShippingAddressId) ?? 0);

string shipAdd = _stateProvinceService.GetStateProvinceByAddress(orderAddress(order)) is StateProvince shippingStateProvince ? _localizationService.GetLocalized(shippingStateProvince, x => x.Name) : string.Empty;


I would like to repeat the steps in the OrderTotalCalculationService.cs -> GetShoppingCartSubTotal() method.  How do I do that please?
2 anni tempo fa
I assume you mean when you are doing a checkout ?
When you are using the Shopping Cart there is no Order
The Order is not created until the Shoping Cart process is Completed
Until then values are the values selected in the Checkout are stored as Generic Attributes and in the Addesses in the WorkContext
2 anni tempo fa
Hi Yidna,

Please refer to this initial Post:  https://www.nopcommerce.com/en/boards/topic/91079/shipping-with-extra-fees-for-out-of-state-clients

I am trying to break this down into separate components to try to take each section step-by-step.
I was able to get through the PdfServices.cs and the MessageTokenProvider.cs and properly display the Extra Shipping Box when the Order is being shipped out of State (Florida) and weigh a certain amount.  
Now I am working on the OrderTotalCalculationService.cs and I think I can add the extra item to the Total if I use the UpdateOrderTotals() Method.  

I think I can get each Item quantity to get the weight with the following code:


           var orderItemQuant = 0;
            foreach (var item in restoredCart)
            {
                orderItemQuant += item.Quantity;
            }


But, I still need to get the Shipping Address State (Florida) to determine the Box size and additional price.  How do I get the Shipping Address from that Method?
2 anni tempo fa
(it's not clear to me that you are doing things the right way, but in any case, to answer your question...)

This parameter of UpdateOrderTotals
UpdateOrderParameters updateOrderParameters

has an UpdatedOrder property, which has property  ShippingAddressId

You can then use a service to get the Address and examine the State.
2 anni tempo fa
Hello,

Thank you for your advice.  I was able to get the calculations working as needed, but, I am stuck on the Admin Section.  
Please observe the New Styrofoam Box entry:



How do I get my generated results from the Cart/Checkout Page to reflect into the Admin Section and PDF Invoice to the Client?

2 anni tempo fa
I'd recommend that you use a Checkout Attribute.  Visually, it would appear above the subtotal area rather than in it, but it's built-in and you would not have to deal with your custom 'line item' anywhere/everywhere, but rather just suppress the checkout attribute prompt from appearing in the shopping cart page.
2 anni tempo fa
Sounds good, how do I implement the CheckOut Attribute?  I found a Documentation here:https://docs.nopcommerce.com/en/running-your-store/order-management/checkout-attributes.html

In my Case, I have a complex requirement, such as:
1. I have a requirement to add a Shipping Box cooler when shipping out of the Warehouse State.
There is a different charge for different sizes, based on the weight of the Cart.
I do not charge or need the box if the user picks-up the package
I do not need the Cooler if the Client is in the same State as my warehouse.

These are the conditions that I had to consider and applied to the cart.  Is this possible in a checkout attribute and it will appear everywhere, including the invoice to the Client?

Thank you for your recommendations.
2 anni tempo fa
First, you should create a text box type checkout attribute in the admin, then go to the cart and enter some $ amount in the checkout attribute text box and continue checkout / confirm the order.  Then verify in all the places you would expect it to appear (admin order, PDF invoice, etc.).    If it does not appear where/how you expect, the it would defeat the purpose of the recommendation.
2 anni tempo fa
Excellent News...  I was able to repair or code all the relevant areas, except one (1).
Where do I adjust the pricing on the List (Admin Section)?  My Styrofoam Cooler price is not getting added to the final Total on this list.
2 anni tempo fa
Not sure what version your on, as haven’t looked through the entire thread, but this is for 4.4.3 : https://github.com/nopSolutions/nopCommerce/blob/12dd4825dfb56bbc64e192cd35d25e3205427646/src/Presentation/Nop.Web/Areas/Admin/Factories/OrderModelFactory.cs#L952
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.