How to check PickUpInStore in Shipping Director?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hello everyone, I'm new for nopCommerce. For now I create a pick up points which system name is "Pickup.PickupInStore", in the front page it is a checkbox. what i want is if i check this, then the shipping fee will be 0, otherwise the shipping fee will generate base on another rule. My problem is I dont know how to get the value of that checkbox is checked or not. Any suggestions will be great. A thousands thanks.
7 years ago
if user has checked pickup at store then PickUpInStore property of order will be true
  

public void HandleEvent(OrderPlacedEvent eventMessage)
        {
            int OrderStatusId = eventMessage.Order.OrderStatusId;
            int OrderId = eventMessage.Order.Id;

            if (eventMessage.Order.PickUpInStore == false)
            {

                // do something
            }
            else
            {
               // do something

                Order.ShippingStatusId = (int)ShippingStatus.ShippingNotRequired;
                _orderService.UpdateOrder(Order);
            }
        }
7 years ago
Hello and thank you for your reply!

But I can't change source code for some reason. Is this can be done in shipping director? Or Is there any way to get the "PickUpInStore" value in shipping director?

Thank you.
7 years ago
i am also not talking about the change in the code. You can create an event listener something like this inside your plugin.

  public class OrderCreatedEventConsumer : IConsumer<OrderPlacedEvent>
{

        private readonly IOrderService _orderService;
        private readonly IShipmentService _shipmentService;
        private readonly ILogger _logger;
        private readonly ICustomerService _customerService;
        private readonly IWorkContext _workContext;
        private readonly IProductService _productService;

        public OrderCreatedEventConsumer(
            IOrderService orderService,
            IShipmentService shipmentService,
            ILogger logger,
            IGenericAttributeService genericAttributeService,
            ICustomerService customerService,
            IWorkContext workContext,
            IProductService productService
            )
        {
            this._orderService = orderService;
            this._shipmentService = shipmentService;
            this._logger = logger;
            this._customerService = customerService;
            this._workContext = workContext;
            this._productService = productService;

        }

  public void HandleEvent(OrderPlacedEvent eventMessage)
        {
            int OrderStatusId = eventMessage.Order.OrderStatusId;
            int OrderId = eventMessage.Order.Id;

            if (eventMessage.Order.PickUpInStore == false)
            {

                // do something
            }
            else
            {
                var Order = eventMessage.Order;

               // do something

                Order.ShippingStatusId = (int)ShippingStatus.ShippingNotRequired;
                _orderService.UpdateOrder(Order);
            }
        }
}


this will be triggered whenever the order is placed. Copy this code put it inside a plugin , place order and start debugging.
7 years ago
Thank you for your reply again!

And sorry... I didn't get you on "Add these code inside plugin"... Is that mean add these code into "Configure.cshtml" of shipping director? if so then I can't go through this way cause I'm not sure this will be acceptable...

For now my shipping director is following this way : https://www.noptools.com/blog/tag/RatePerItem, So I wonder if it is possible to add an variable like that to achieve the goal.

Really thanks for your reply!
7 years ago
No we won't be touching anything inside the nop.web
plugins is the place where you do you custom coding so that your core remains exactly as given by nop commerce.
  
I am guessing that you are complete new to nopcommerce ( like me :p ). Anyways you first need to create a plugin, now that you are completely new what you can do is

1) create this class that i gave the example of inside your pickupInStorePlugin [ Nop.Plugin.Pickup.PickupInStore ] just add this class and put a breakpoint on handle event.

2) host the site on iis and attach the process [  ctrl + alt + p  -> w3wp.exe ]

3) place order

once the order is placed then your break point will hit.

so that way you can manipulate the order. like in the example i set the shipping method as shipping not required in case of pickupInStore
7 years ago
Thanks for your reply!

To be honest, I'm totally complete new for nop :D, cause I still don't understand your function....

It looks like I need to create a class file inside of "..\Presentation\Nop.Web\Plugins\Pickup.PickupInStore". Is that right? or somewhere else?

I will try this tomorrow.

Thanks a lot for your help!
7 years ago
Yes you are correct. Since you don't have any clue :p just focus on point one.
create this class inside the plugin and do whatever code you want to do. eventmessage.Order will give you the current Order. now you can manipulate the order or do some additional task like calling the courier partner if pikcupinstore is false or custom email to store if pickupinstore is true.

1 thing to remember is since you are creating this class inside the pickupinstore plugin so this class will be active only when the pickupinstore plugin is installed and enabled. if you disable the plugin then this won't work. [ that is the reason i suggested creating a new standalone plugin but that we can do later if required ].  :)
7 years ago
xiangzheng0000 wrote:
Hello everyone, I'm new for nopCommerce. For now I create a pick up points which system name is "Pickup.PickupInStore", in the front page it is a checkbox. what i want is if i check this, then the shipping fee will be 0, otherwise the shipping fee will generate base on another rule. My problem is I dont know how to get the value of that checkbox is checked or not. Any suggestions will be great. A thousands thanks.


I use ShippingDirector plugin, and this is what we do:
Rather than using the "Pick up in store" setting in nopComerce, (I leave it unchecked)
I create an option in ShippingDirector:
OPTION  >> In-Store Pickup >> [$CurrentStoreId]=1 and [isDomestic]  >> 0 >> -- >> -- >> "Customer pick-up at our store." >> --
7 years ago
If the customer chooses a Pickup Point, nopCommerce does not get shipping methods/rates.  Thus, Shipping Director is never called.  As per embryo, you can use Shipping Director and create an Option for your pickup point. (The only downside is that the customer will have to enter a shipping address first.)  But, you say "check this, then the shipping fee will be 0" - that is the default for pickup points unless you've set a fee on the pickup point.  So, I don't understand the problem you are having.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.