What is purpose of Basket Content Hash and How is it Used?
What is purpose of Basket Content Hash and How is it Used?
What is purpose of the ContentHash field in ac_Baskets? How is it used?
When I looked through the code, it only seems to be used by Google Checkout but it's not clear what it represents and when it is assigned a value or have its value changed.
Thanks
When I looked through the code, it only seems to be used by Google Checkout but it's not clear what it represents and when it is assigned a value or have its value changed.
Thanks
- Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Re: What is purpose of Basket Content Hash and How is it Used?
It is a hash value that helps us determine if anything within the basket has changed. This allows us to do things like caching of shipping rates or asynchronous checkouts (like google). The value is constructed something like
basket id:shipment 1 id:shipment 1 address:shipment 1 contents:shipment 2 id:etc
Then that is turned into an MD5 hash.
basket id:shipment 1 id:shipment 1 address:shipment 1 contents:shipment 2 id:etc
Then that is turned into an MD5 hash.
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Logan

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Re: What is purpose of Basket Content Hash and How is it Used?
I would recommend you use this in the future to make the checkout smarter. If any basket changes updated this hash value, you could then check for changes inside the Basket.Package() method and prevent the basket shipment information being lost whenever the user leaves the checkout process but doesn't make any changes. For example, if you use multiple destinations, the checkout process is not forgiving.
I can't find the post now but as an additional comment, it would be useful if the proprietary CommerceBuilder classes were completely inherited by source code stubs that just called the internal base methods. If the rest of the AC code called these stubs, users could then add their own logic around existing functions without having to track down every instance of a particular call.
I can't find the post now but as an additional comment, it would be useful if the proprietary CommerceBuilder classes were completely inherited by source code stubs that just called the internal base methods. If the rest of the AC code called these stubs, users could then add their own logic around existing functions without having to track down every instance of a particular call.
- Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Re: What is purpose of Basket Content Hash and How is it Used?
A bug stating something similar was registered recently I believe.ZLA wrote:I would recommend you use this in the future to make the checkout smarter. If any basket changes updated this hash value, you could then check for changes inside the Basket.Package() method and prevent the basket shipment information being lost whenever the user leaves the checkout process but doesn't make any changes. For example, if you use multiple destinations, the checkout process is not forgiving.
If it were that simple. We could make a library of stubs that inherited from the base classes. This library would have to reference the base library. But in order for this to work the base library would in turn have to reference the stub library. Circular references aren't allowed that way.ZLA wrote:I can't find the post now but as an additional comment, it would be useful if the proprietary CommerceBuilder classes were completely inherited by source code stubs that just called the internal base methods. If the rest of the AC code called these stubs, users could then add their own logic around existing functions without having to track down every instance of a particular call.
We have internally discussed other approaches that have the same goal. It would be nice if on a custom basis you could inherit from any of our classes and override with your own functionality. I much prefer that to selling source packages because of the difficulty that comes with upgrading customized source.
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Logan

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Re: What is purpose of Basket Content Hash and How is it Used?
I agree with the inheriting. The goal is to make it more easily customizable and / or extensible, not how to achieve it.
Re: What is purpose of Basket Content Hash and How is it Used?
There are two overloads for GetContentHash that include an array of OrderItemType:Logan_AbleCommerce wrote:It is a hash value that helps us determine if anything within the basket has changed.
- GetContentHash(OrderItemType[])
- GetContentHash(bool includeUserAddress, bool includeShipments, bool includeUserInputFields, OrderItemType[])
If the latter, what would I need to pass in to include all OrderItemTypes?
Thanks.
- Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Re: What is purpose of Basket Content Hash and How is it Used?
OrderItemType arguments can be null. In that case, all types are included.
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Logan

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.