Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store Location Address model’s isStoreLocation is false #1773

Closed
mattstein opened this issue Oct 7, 2020 · 2 comments
Closed

Store Location Address model’s isStoreLocation is false #1773

mattstein opened this issue Oct 7, 2020 · 2 comments
Labels

Comments

@mattstein
Copy link
Contributor

mattstein commented Oct 7, 2020

Emoji Summary

🤔 🤷‍♂️

Description

When I use craft\commerce\services\Addresses::getStoreLocationAddress(), the correct address information is returned but its isStoreLocation is false even though its column has a 1 in the database.

Maybe it’s an issue in MySQL only and not Postgres?

To Reproduce

  1. In the control panel, navigate to Commerce → Store Settings → Store Location, enter a humorous test address, and choose “Save”.
  2. Add the following to a Twig template:
{% set storeAddress = craft.commerce.addresses.getStoreLocationAddress() %}
<pre>{{ storeAddress | json_encode(constant('JSON_PRETTY_PRINT')) }}</pre>
<pre>{{ dump(storeAddress) }}</pre>
  1. In a browser, navigate to a page that uses that template. Observe the correct address information, but that in each representation of it isStoreLocation is false.
  2. In your favorite MySQL client, connect to the site’s database and find the relevant row in the commerce_addresses table. Observe that isStoreLocation is 1.

Expected behavior

The getStoreLocationAddress() method returns the expected record, but I expected its isStoreLocation to be true or 1 and it’s false instead.

Additional info

  • Craft version: 3.5.11.1, 3.5.12.1
  • Commerce version: dev-develop (e335763)
  • PHP version: 7.3.15, 7.4.3
  • Database driver & version: MySQL 5.5.5
@mattstein mattstein added the New label Oct 7, 2020
@mattstein mattstein changed the title Store Location Address model’s isStoreLocation is false. Store Location Address model’s isStoreLocation is false Oct 7, 2020
@mattstein
Copy link
Contributor Author

mattstein commented Oct 7, 2020

Probably related but also weird: isEstimated is returned as a string ('0') while isStoreLocation is a boolean (false). Example:

object(craft\commerce\models\Address)#748 (35) {
  ["id"] => string(1) "3"
  ["isStoreLocation"] => bool(false)
  ["attention"] => string(0) ""
  ["title"] => string(0) ""
  ["firstName"] => string(0) ""
  ["lastName"] => string(0) ""
  ["fullName"] => string(0) ""
  ["address1"] => string(25) "1234 Balboa Towers Circle"
  ["address2"] => string(4) "#100"
  ["address3"] => string(0) ""
  ["city"] => string(11) "Los Angeles"
  ["zipCode"] => string(5) "92662"
  ["phone"] => string(14) "(555) 555-5555"
  ["alternativePhone"] => string(0) ""
  ["label"] => string(0) ""
  ["businessName"] => string(17) "Gobias Industries"
  ["businessTaxId"] => string(5) "12345"
  ["businessId"] => string(0) ""
  ["stateName"] => string(0) ""
  ["countryId"] => string(3) "236"
  ["stateId"] => string(2) "26"
  ["notes"] => string(0) ""
  ["custom1"] => string(0) ""
  ["custom2"] => string(0) ""
  ["custom3"] => string(0) ""
  ["custom4"] => string(0) ""
  ["isEstimated"] => string(1) "0"
  ["_stateValue":"craft\commerce\models\Address":private] => NULL
  ["_vatValidator":"craft\commerce\models\Address":private] => NULL
  ["_errors":"yii\base\Model":private] => NULL
  ["_validators":"yii\base\Model":private] => NULL
  ["_scenario":"yii\base\Model":private] => string(7) "default"
  ["_events":"yii\base\Component":private] => array(0) {}
  ["_eventWildcards":"yii\base\Component":private] => array(0) {}
  ["_behaviors":"yii\base\Component":private] => array(0) {}
}

@lukeholder
Copy link
Member

What a perfect bug report! Fixed for the next release in 07d5411. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants