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

Merchant Center Settings Sync #255

Merged
merged 34 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5166b61
Create the Settings sync class
JPry Feb 24, 2021
af0d386
Remove default limit from query
JPry Feb 24, 2021
b814045
Register the Settings class in the container
JPry Feb 25, 2021
4e2bc96
Create the settings sync API controller
JPry Feb 25, 2021
4478388
Include a response for setting sync
JPry Feb 25, 2021
fc030b9
Type-hint against ValueInterface
JPry Mar 1, 2021
656e5d8
Separate method for the time object
JPry Mar 1, 2021
9d2ff57
Import classes used in the logger
JPry Mar 2, 2021
84c6ac3
Update settings sync and handle exceptions
JPry Mar 2, 2021
23ea44d
Use aliases for Google classes
JPry Mar 3, 2021
60c8e36
Remove limit parameter from rate query
JPry Mar 3, 2021
df86ff7
Add currency to the settings
JPry Mar 3, 2021
259fdb6
Update return value for sync
JPry Mar 3, 2021
5491c1c
Create InvalidType exception
JPry Mar 3, 2021
860f404
Create EnumeratedValues class
JPry Mar 3, 2021
4ae6cf8
Create RateType value
JPry Mar 3, 2021
6dd3282
Rework setting sync to account for the possibility of free shipping
JPry Mar 3, 2021
a160b80
Initial block to synchronize taxes
JPry Mar 4, 2021
64937c5
Ensure we only sync taxes in the US
JPry Mar 4, 2021
8e8ccda
Trigger tax sync from the API
JPry Mar 4, 2021
0a30d2d
Create location ID trait for mapping Google locations
JPry Mar 6, 2021
7013867
Add a method to retrieve tax settings
JPry Mar 6, 2021
1270c0b
Add uniqueness and more detail to the shipping service name
JPry Mar 6, 2021
8292013
Add settings class vs. share
JPry Mar 6, 2021
5ce3248
Add action when exception is caught
JPry Mar 6, 2021
9f0149e
Clean up exception handling a bit for setting save
JPry Mar 6, 2021
db0784f
Add an action when a settings sync has taken place
JPry Mar 6, 2021
6a85d97
Use the correct value for free shipping minimum
JPry Mar 8, 2021
acae3d8
Create ContainerAware trait and interface
JPry Mar 8, 2021
8fc1c4e
Create class to handle starting the product sync
JPry Mar 8, 2021
5815210
Fix spacing for ConnectionTest file
JPry Mar 8, 2021
901f40f
Add class to update the setup completed option
JPry Mar 8, 2021
86f20ac
Add initial version of MerchantCenterSettings value object
JPry Mar 6, 2021
eb42f33
Check for whether shipping settings should be synced or not
JPry Mar 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<properties>
<property name="exclude" type="array">
<element value="json_encode"/>
<element value="rand"/>
</property>
</properties>
</rule>
Expand Down
93 changes: 93 additions & 0 deletions src/API/Google/LocationIDTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\API\Google;

use Automattic\WooCommerce\GoogleListingsAndAds\Exception\InvalidState;

defined( 'ABSPATH' ) || exit;

/**
* Trait LocationIDTrait
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\API\Google
*/
trait LocationIDTrait {

/**
* Mapping data for location IDs.
*
* @see https://developers.google.com/adwords/api/docs/appendix/geotargeting
*
* @var string[]
*/
protected $mapping = [
'AL' => 21133,
'AK' => 21132,
'AZ' => 21136,
'AR' => 21135,
'CA' => 21137,
'CO' => 21138,
'CT' => 21139,
'DE' => 21141,
'DC' => 21140,
'FL' => 21142,
'GA' => 21143,
'HI' => 21144,
'ID' => 21146,
'IL' => 21147,
'IN' => 21148,
'IA' => 21145,
'KS' => 21149,
'KY' => 21150,
'LA' => 21151,
'ME' => 21154,
'MD' => 21153,
'MA' => 21152,
'MI' => 21155,
'MN' => 21156,
'MS' => 21158,
'MO' => 21157,
'MT' => 21159,
'NE' => 21162,
'NV' => 21166,
'NH' => 21163,
'NJ' => 21164,
'NM' => 21165,
'NY' => 21167,
'NC' => 21160,
'ND' => 21161,
'OH' => 21168,
'OK' => 21169,
'OR' => 21170,
'PA' => 21171,
'RI' => 21172,
'SC' => 21173,
'SD' => 21174,
'TN' => 21175,
'TX' => 21176,
'UT' => 21177,
'VT' => 21179,
'VA' => 21178,
'WA' => 21180,
'WV' => 21183,
'WI' => 21182,
'WY' => 21184,
];

/**
* Get the location ID for a given state.
*
* @param string $state
*
* @return int
* @throws InvalidState When the provided state is not found in the mapping.
*/
protected function get_state_id( string $state ): int {
if ( ! array_key_exists( $state, $this->mapping ) ) {
throw InvalidState::from_state( $state );
}

return $this->mapping[ $state ];
}
}
Loading