When comparing two Drop objects using an if statement, the results of valueOf are not compared.
Will cause this judgment logic to be false all the time.
Refer to the address and AddresDrop objects in Shopify, and compare them according to the valueOf result.
Javascript:
class AddressDrop extends Drop {
constructor() {
super()
}
valueOf() {
return 'test'
}
}
const address = new AddressDrop()
const customer = {
default_address: new AddressDrop()
}
HTML:
{%- if address == customer.default_address -%}
<h2>{{ 'customer.addresses.default' | t }}</h2>
{%- endif -%}
When comparing two Drop objects using an if statement, the results of valueOf are not compared. Will cause this judgment logic to be false all the time. Refer to the address and AddresDrop objects in Shopify, and compare them according to the valueOf result.
Javascript:
HTML: