When selecting New credit card as the payment type during checkout the store's default/set country is not inherited in the payment information form.

Currently, it defaults to the top alphabetical country that is allowed.

If an existing card is chosen prior to selecting a New credit card the country is updated. Unsure if that updates to the value tied to the card or to the store's default country.

Comments

ericshell created an issue. See original summary.

sumanthkumarc’s picture

bojanz’s picture

Closed #2891382: payment info - how does one remove "greece" default country? as a duplicate, there's more information on that issue.

websiteworkspace’s picture

So, what is the fix for this problem?

How does remove that unwanted "country" that appears in the payment information form?

---

As hinted at above (1), when I setup another test D8 DC 2.x, and something went a little differently in the workflow (not certain), that extra unwanted "country" hasn't appeared (whereever the heck it is stored in the sea of entities).

---

Key question - - -

Is that field editable somewhere, and if not, why not, and why isn't "everything" editable at some level from the Commerce admin UI?

(1)

If an existing card is chosen prior to selecting a New credit card the country is updated. Unsure if that updates to the value tied to the card or to the store's default country.
bojanz’s picture

@DrupalWebsiteBuilder
The list of allowed billing countries is taken from the store entity.
If an address has a non-allowed country (created before the restriction), that country will also be available in the list, to preserve data integrity.

This issue is saying that there is a bug that causes the default country to be ignored (instead of reflecting the store's billing country. The wrong value might also be reflected in the dropdown. Not sure yet, since I haven't investigated.

websiteworkspace’s picture

@bojanz ....

The problem above occurred when creating a test Drupal 8 commerce site from a clean newly installed Drupal 8 instance without any direct user/admin operations on the address module (not directly anyway), (address module installed by and up to date via composer) other than trying to setup a test Drupal 8 commerce site.

The secondary problem here is that there doesn't seem to be any admin UI facility where this problem can be repaired, or is there, and if so where is it so that I can others can fix this problem?

I am not even in Europe or any European timezone, nor is any user on the newly spun Drupal instance, so it is a puzzle how the commerce code randomly selected "Greece" as a default country and installed in the store object, which doesn't appear to editable in a way that the problem can be corrected later.

-

For my efforts, I 'm going to just mothball that problem Drupal test instance, (to be kept in .gz archive for post mortem by anyone interested), and build more, but this is a concerning problem, especially since there doesn't appear to be a way to repair the broken Drupal commerce store from the admin UI.

If numerous other people encounter this problem, they are sure to be concerned I would imagine.

The problem Drupal commerce instance remains available in a .gz archive of an archive of the sql and code.

websiteworkspace’s picture

@bojanz ...

I did some further testing of the problem describe above, in my previous bug report (linked below), and further in my description below.

I built yet another test Drupal 8 site, from base install, using the dev branch of the commerce and address modules.

Instead of the sequence:
add to cart
checkout
payment information
-
I first went to:
{site}user/1/payment-methods/add
multiple problems were visible

1. the card number shown is not the card number of the one and only test payment gateway I configured.
2. who ever wrote the underlying code has clearly hard coded "Greece" as the default country.
3. the field are not setup for U.S. - state, zipcode - despite the fact that the one and only store object, has "United State" set as the onl "supported billing countries" entry.
4. Only AFTER clicking the SAVE button at - add payment method - does the field layout update to U.S. style fields and display an ERROR that the - state - wasn't set, although the - state - field hadn't been displayed in the first place.
- this is really, really, really, bad customer experience (UX), a serious UX bug.
5. There doesn't appear to be any commerce admin UI provided anywhere to fix the hard coded "Greece" default country problem that is occurring.

-

I built this free D8 DC 2.x commerce from clean setup using a composer.json set for the latest DC 2.x dev branch releases. I also made incremental backups of the configuration along the way, so that I rollback and retry. However, it is clear that somewhere in the pre-populated DC 2.x entity schema, Greece and European country field setup assumptions are hard coded and baked into the default entity contents.

-

The fact that the hard coded Greece contents shows up both when the user tries to create a payment method from the user profile pages, and also if going to checkout without a pre-configured payment method, really is three (3) bugs:
- payment method setup implementation problem.
- default checkout implementation problem.
- default underlying entity schema implementation problem that doesn't configure itself based on the settings defined in the store object that was already created and configured.

------

(see my prior bug report about these related problems)
https://www.drupal.org/node/2891382

websiteworkspace’s picture

@bojanz - specific follow-up to #5

The one and only store object I created on both test sites not contain "Greece" as a billing country.

The only billing country configured in the one and only store object I setup in these testing sites is "United States".

Consequently, if the code is actually pulling from the store.

----

I have the test available for perusal and reproduction of these problems.
I have available gzip archives of the SQL and Drupal code base which you can install on your own server and test with, reproduce and verify yourself.

----

You mention "data integrity" bug the commerce admin UI doesn't provide any UI to remove and repair the "billing country/countries" configured in the store object. I only setup "United States" but twice now, "Greece" has appeared, apparently hard coded as a default by the whoever implemented that code.

----

Feel free to either obtain a copy of the test site from me, or obtain an admin login to the test site to examine the configuration yourself.

----

The DC 2.x code contains multiple bugs in this regard.

websiteworkspace’s picture

Further investigation ...

I exported the SQL database for the newest DC 2.x test site I created and checked to see if there was a Greece (GR) country code anywhere in any of the related database tables, but there aren't any.

Despite the fact that Greece is not stored in the database, the relevant user-interface components:
- create payment method form
- checkout payment information form

Both populate their forms with Greece as the country and display both Greece and the actual U.S. country as options in the country selection field.

-----



--
-- Table structure for table `commerce_store`
--

CREATE TABLE IF NOT EXISTS `commerce_store` (
  `store_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `type` varchar(32) CHARACTER SET ascii NOT NULL COMMENT 'The ID of the target entity.',
  `uuid` varchar(128) CHARACTER SET ascii NOT NULL,
  `langcode` varchar(12) CHARACTER SET ascii NOT NULL,
  PRIMARY KEY (`store_id`),
  UNIQUE KEY `commerce_store_field__uuid__value` (`uuid`),
  KEY `commerce_store_field__type__target_id` (`type`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COMMENT='The base table for commerce_store entities.' AUTO_INCREMENT=2 ;

--
-- Dumping data for table `commerce_store`
--

INSERT INTO `commerce_store` (`store_id`, `type`, `uuid`, `langcode`) VALUES
(1, 'online', '3a6d3f4b-6e25-4560-bf69-242955d2dbdc', 'en');

-- --------------------------------------------------------

--
-- Table structure for table `commerce_store_field_data`
--

CREATE TABLE IF NOT EXISTS `commerce_store_field_data` (
  `store_id` int(10) unsigned NOT NULL,
  `type` varchar(32) CHARACTER SET ascii NOT NULL COMMENT 'The ID of the target entity.',
  `langcode` varchar(12) CHARACTER SET ascii NOT NULL,
  `uid` int(10) unsigned DEFAULT NULL COMMENT 'The ID of the target entity.',
  `name` varchar(255) DEFAULT NULL,
  `mail` varchar(254) DEFAULT NULL,
  `default_currency` varchar(255) CHARACTER SET ascii DEFAULT NULL COMMENT 'The ID of the target entity.',
  `address__langcode` varchar(32) DEFAULT NULL,
  `address__country_code` varchar(2) DEFAULT NULL,
  `address__administrative_area` varchar(255) DEFAULT NULL,
  `address__locality` varchar(255) DEFAULT NULL,
  `address__dependent_locality` varchar(255) DEFAULT NULL,
  `address__postal_code` varchar(255) DEFAULT NULL,
  `address__sorting_code` varchar(255) DEFAULT NULL,
  `address__address_line1` varchar(255) DEFAULT NULL,
  `address__address_line2` varchar(255) DEFAULT NULL,
  `address__organization` varchar(255) DEFAULT NULL,
  `address__given_name` varchar(255) DEFAULT NULL,
  `address__additional_name` varchar(255) DEFAULT NULL,
  `address__family_name` varchar(255) DEFAULT NULL,
  `default_langcode` tinyint(4) NOT NULL,
  `prices_include_tax` tinyint(4) DEFAULT NULL,
  PRIMARY KEY (`store_id`,`langcode`),
  KEY `commerce_store__id__default_langcode__langcode` (`store_id`,`default_langcode`,`langcode`),
  KEY `commerce_store_field__type__target_id` (`type`),
  KEY `commerce_store_field__uid__target_id` (`uid`),
  KEY `commerce_store__a0c0b29304` (`default_currency`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='The data table for commerce_store entities.';

--
-- Dumping data for table `commerce_store_field_data`
--

INSERT INTO `commerce_store_field_data` (`store_id`, `type`, `langcode`, `uid`, `name`, `mail`, `default_currency`, `address__langcode`, `address__country_code`, `address__administrative_area`, `address__locality`, `address__dependent_locality`, `address__postal_code`, `address__sorting_code`, `address__address_line1`, `address__address_line2`, `address__organization`, `address__given_name`, `address__additional_name`, `address__family_name`, `default_langcode`, `prices_include_tax`) VALUES
(1, 'online', 'en', 1, 'Store', 'store@testsite.com', 'USD', '', 'US', 'OR', 'Bend', NULL, '97007', NULL, '123 Test Street', '', NULL, NULL, NULL, NULL, 1, 0);

-- --------------------------------------------------------

--
-- Table structure for table `commerce_store__billing_countries`
--

CREATE TABLE IF NOT EXISTS `commerce_store__billing_countries` (
  `bundle` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance',
  `deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'A boolean indicating whether this data item has been deleted',
  `entity_id` int(10) unsigned NOT NULL COMMENT 'The entity id this data is attached to',
  `revision_id` int(10) unsigned NOT NULL COMMENT 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id',
  `langcode` varchar(32) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The language code for this data item.',
  `delta` int(10) unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields',
  `billing_countries_value` varchar(255) NOT NULL,
  PRIMARY KEY (`entity_id`,`deleted`,`delta`,`langcode`),
  KEY `bundle` (`bundle`),
  KEY `revision_id` (`revision_id`),
  KEY `billing_countries_value` (`billing_countries_value`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Data storage for commerce_store field billing_countries.';

--
-- Dumping data for table `commerce_store__billing_countries`
--

INSERT INTO `commerce_store__billing_countries` (`bundle`, `deleted`, `entity_id`, `revision_id`, `langcode`, `delta`, `billing_countries_value`) VALUES
('online', 0, 1, 1, 'en', 0, 'US');

-- --------------------------------------------------------

--
-- Table structure for table `commerce_store__tax_registrations`
--

CREATE TABLE IF NOT EXISTS `commerce_store__tax_registrations` (
  `bundle` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance',
  `deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'A boolean indicating whether this data item has been deleted',
  `entity_id` int(10) unsigned NOT NULL COMMENT 'The entity id this data is attached to',
  `revision_id` int(10) unsigned NOT NULL COMMENT 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id',
  `langcode` varchar(32) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The language code for this data item.',
  `delta` int(10) unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields',
  `tax_registrations_value` varchar(255) NOT NULL,
  PRIMARY KEY (`entity_id`,`deleted`,`delta`,`langcode`),
  KEY `bundle` (`bundle`),
  KEY `revision_id` (`revision_id`),
  KEY `tax_registrations_value` (`tax_registrations_value`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Data storage for commerce_store field tax_registrations.';

--
-- Dumping data for table `commerce_store__tax_registrations`
--

INSERT INTO `commerce_store__tax_registrations` (`bundle`, `deleted`, `entity_id`, `revision_id`, `langcode`, `delta`, `tax_registrations_value`) VALUES
('online', 0, 1, 1, 'en', 0, 'US');

--------------------------------------------------------




websiteworkspace’s picture

Here are images of the error symptoms on the checkout flow - order information - page, as described by ericshell and myself:

The following image shows the - order information - page with the phantom "Greece" country selected, which is not in the SQL database. The phantom Greece country is even selected as default (see copy of actual html markup below from the page source).

check order information page - showing phantom "greece" country not in commerce database

The following image show the page with error message display after "continue to review" is clicked, after the page reloads, and only then shows the U.S. state field, which is empty because it wasn't available previously.

check order information page - error after review button click


<div data-drupal-selector="edit-payment-information-add-payment-method-billing-information" id="edit-payment-information-add-payment-method-billing-information" class="js-form-wrapper form-wrapper"><div class="field--type-address field--name-address field--widget-address-default js-form-wrapper form-wrapper" data-drupal-selector="edit-payment-information-add-payment-method-billing-information-address-wrapper" id="edit-payment-information-add-payment-method-billing-information-address-wrapper">      <div data-drupal-selector="edit-payment-information-add-payment-method-billing-information-address-0" id="edit-payment-information-add-payment-method-billing-information-address-0" class="js-form-wrapper form-wrapper"><div id="payment-information-add-payment-method-billing-information-address-0-address-ajax-wrapper"><div data-drupal-selector="edit-payment-information-add-payment-method-billing-information-address-0-address" id="edit-payment-information-add-payment-method-billing-information-address-0-address" class="js-form-wrapper form-wrapper"><div data-drupal-selector="edit-payment-information-add-payment-method-billing-information-address-0-address-country-code" id="edit-payment-information-add-payment-method-billing-information-address-0-address-country-code" class="js-form-wrapper form-wrapper"><div class="js-form-item form-item js-form-type-select form-type-select js-form-item-payment-information-add-payment-method-billing-information-address-0-address-country-code form-item-payment-information-add-payment-method-billing-information-address-0-address-country-code">
      <label for="edit-payment-information-add-payment-method-billing-information-address-0-address-country-code--2" class="js-form-required form-required">Country</label>
        <select class="country form-select required" autocomplete="country" data-drupal-selector="edit-payment-information-add-payment-method-billing-information-address-0-address-country-code" id="edit-payment-information-add-payment-method-billing-information-address-0-address-country-code--2" name="payment_information[add_payment_method][billing_information][address][0][address][country_code]" required="required" aria-required="true"><option value="GR" selected="selected">Greece</option><option value="US">United States</option></select>
        </div>
</div>



websiteworkspace’s picture

The following mp4 screencast demonstrates the problems reported above:

http://d8dc.sitebase.space/screencasts/d8dc2x-checkout-anon-basic.mp4

At 0:47 m:s - in the screencast - see that the "Greece" default country is displayed, although Greece does not exist in the database.

At 0:48 m:s - see that the country is changed to "Untied States" (only one in database store object) but the rest of the form doesn't update after the change, to include the U.S. State field.

At 1:34 m:s - only after clicking "continue to review" does the form update, but displays an "error" because the previously non-existent U.S. state field is empty.

------

Some of the problems observable in the screencast:

1. The checkout process should not display a country that does not even exist in the database.
2. Once a country is changed, the form should update and add country specific fields, such as the U.S. state, or Canadian province, if the country is changed to "United States" or "Canada" from a country without regional subdivisions.

-------

p.s. note - (see 1:55 m:s It seems like the Review page should include the Billing Address Information, not just the card information.

Submitting D8 Commerce 2.x software problem reports to help make DC 2.x the best it might be.

websiteworkspace’s picture

ADDITIONAL INFORMATION ABOUT THIS BUG ...

The problem illustrated above occurs when the country set in the site global regional settings differs from the supported billing country(ies) set in the commerce store object.

Something in the Commerce code is fetching the site global default country, even though that country is not in the store object, when the site global default country differs from the one and only billing country set in the commerce store object. Whatever logic in the commerce code does that needs to be changed so that the commerce software only selects its default country from a country set in the commerce object. Apparently the commerce code checks the site regional settings when looking for the correct default country, rather than first looking at the contents of the store object and using that country, even if it differs from the site's global regional settings.

-- There is probably a preferred behavior discussion that needs to take place about how to best approach that conflict, with consideration that the current logic isn't working appropriately.

When I changed the global site default country at:

{site}/admin/config/regional/settings

to match the one and only billing country set in the one and only store object, the problem that is apparent in the screencast above disappeared.

The problem visible in the screencast above needs to be fixed so that sites that do need to support commerce to and from multiple/differing countries will display the appropriate country settings correctly during the payment method setup phase of the checkout process.

--

There is a separate problem that is apparent in the screencast above, that probably needs its own bug report, which is that when the country is changed in the payment method setup form, the form does not update all the fields to configure custom fields needed for the chosen country (as is visible in the screencast above).

bojanz’s picture

Priority: Normal » Major
Status: Active » Fixed

This has been a very tough one to figure out. Took me several tries.

There are multiple bugs at play here, DrupalWebsiteBuilder's last comment helped me reproduce all of them.

Commerce had a bug where it set the default country to the site default. This was causing it to appear in the dropdown. An Address bug caused #ajax to crash if there's only one available country + a default country that's not available.

Fixed the following bugs in Commerce:
#2908568: Remove the "Site default" default country from the profile address field
#2908571: ProfileSelect should validate that the default country is allowed
And fixed the following bug in Address:
#2908575: Crash when there's only one available country + another one

This fixes the issues DrupalWebsiteBuilder, which were not the same as the original issue, which that the default country is not selected properly when switching between payment methods at checkout. Turns out that bug also had roots in #2908575: Crash when there's only one available country + another one, so when I fixed that issue, it was solved.

All in all: You'll need Commerce 2.0-RC3, which I am tagging in a few hours, and Address 1.2, which lands this week.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.