I put a console.log('blah... ') message in ssp_lib...
# suitecommerce
c
I put a console.log('blah... ') message in ssp_libraries_ext.js to check some variables but I'm seeing it executed 3 times. Is that normal? Could this be related to having 3 domain setup records?
p
after doing what do you see three logs?
after hitting a service or after loading a page?
because a generic log could be excecuted up to 6 times after loading a page: • shopping.ssp • shopping environment • shopping shortcache environment • shopping user environment • liveorder • productlist
but the first three might hit caches😁
c
I'm hitting a service. LiveOrder.Service.ss
p
and where in the code did you write the console.log?
c
In the get method of LiveOrderModel
It's overriden, I should add.
p
yeah, that was going to be my next question.
and you're doing a GET request?
c
It's a PUT
p
ah then it's normal
c
So what are the first two?
p
the code compares the previous state (obtained via get) before doing any changes.
c
Hmmm... interesting.
p
which version are you in?
c
2019.1
p
Copy code
update: function update (data)
   {

      var current_order = this.get()
(in liveorder.model)
actually...
Copy code
,   update: function update (data)
   {

      var current_order = this.get()
      // We use this because we do not want to update certain atributes of the order if they had the same value as the provided as update's input.
      // This is because, through the Extensibility API, an extension may have made some changes to the order and those may be overwritten if the update's input has a different value.
      ,  pre_update_order = this.get();
there you have the first 2
and of course the third is just the get used to return you the order after modifications
c
Wow.
p
It looks worse than it actually is, i have worked in optimizing performance and those first two calls don't cause the performance hit you'd expect
that's because doing multiple gets just hits internal NS caches
c
thanks for detailing this out
p
as long as you don't do anything that triggers a recalculation of the sales order, that is blazingly fast (<10 secs)
(like adding things to cart, or changing payments, shipping, etc)
c
Sometimes I make changes... eeek
changing shipping methods
I need to think through this...
p
If you further explain what you mean by changing shipping methods perhaps i can help a little bit
there are multiple interpretations
c
If a customer selects a certain shippingmethod (i.e. Will Call) then I add/set the shipping address for tax purposes.
So I guess I don't change the shippingmethod, just the selected address.
p
what i would start by doing is
Copy code
Application.on('before:LiveOrder.update', function beforeLiveOrderUpdate(Model, cart) {

here i'd set the shipping address, before the shipping method code runs

})
c
Ummm, yea, lol. That's a lot cleaner than what I'm fumbling with.
p
Poor man's store pickup... have implemented this multiple times 😄
c
I waaay over complicated this. I owe you a bar tab.
Thanks so much!
p
🙂
🍻 1