AdditionalPayments.php
1 year ago
Appearance.php
2 years ago
CustomizeStore.php
5 months ago
ExperimentalShippingRecommendation.php
5 months ago
ExtendStore.php
1 year ago
GetMobileApp.php
3 years ago
LaunchYourStore.php
2 years ago
Marketing.php
7 months ago
Payments.php
10 months ago
Products.php
1 month ago
ReviewShippingOptions.php
3 years ago
Shipping.php
3 months ago
StoreCreation.php
4 years ago
StoreDetails.php
3 years ago
Tax.php
1 year ago
TourInAppMarketplace.php
2 years ago
WooCommercePayments.php
5 months ago
StoreDetails.php
87 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks; |
| 4 | |
| 5 | use Automattic\WooCommerce\Internal\Admin\Onboarding\OnboardingProfile; |
| 6 | use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task; |
| 7 | |
| 8 | /** |
| 9 | * Store Details Task |
| 10 | */ |
| 11 | class StoreDetails extends Task { |
| 12 | /** |
| 13 | * ID. |
| 14 | * |
| 15 | * @return string |
| 16 | */ |
| 17 | public function get_id() { |
| 18 | return 'store_details'; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Title. |
| 23 | * |
| 24 | * @return string |
| 25 | */ |
| 26 | public function get_title() { |
| 27 | if ( true === $this->get_parent_option( 'use_completed_title' ) ) { |
| 28 | if ( $this->is_complete() ) { |
| 29 | return __( 'You added store details', 'woocommerce' ); |
| 30 | } |
| 31 | return __( 'Add store details', 'woocommerce' ); |
| 32 | } |
| 33 | return __( 'Store details', 'woocommerce' ); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Content. |
| 38 | * |
| 39 | * @return string |
| 40 | */ |
| 41 | public function get_content() { |
| 42 | return __( |
| 43 | 'Your store address is required to set the origin country for shipping, currencies, and payment options.', |
| 44 | 'woocommerce' |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Time. |
| 50 | * |
| 51 | * @return string |
| 52 | */ |
| 53 | public function get_time() { |
| 54 | return __( '4 minutes', 'woocommerce' ); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Time. |
| 59 | * |
| 60 | * @return string |
| 61 | */ |
| 62 | public function get_action_url() { |
| 63 | return ! $this->is_complete() ? admin_url( 'admin.php?page=wc-settings&tab=general&tutorial=true' ) : admin_url( 'admin.php?page=wc-settings&tab=general' ); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Task completion. |
| 68 | * |
| 69 | * @return bool |
| 70 | */ |
| 71 | public function is_complete() { |
| 72 | $country = WC()->countries->get_base_country(); |
| 73 | $country_locale = WC()->countries->get_country_locale(); |
| 74 | $locale = $country_locale[ $country ] ?? array(); |
| 75 | |
| 76 | $hide_postcode = $locale['postcode']['hidden'] ?? false; |
| 77 | // If postcode is hidden, just check that the store address and city are set. |
| 78 | if ( $hide_postcode ) { |
| 79 | return get_option( 'woocommerce_store_address', '' ) !== '' && get_option( 'woocommerce_store_city', '' ) !== ''; |
| 80 | } |
| 81 | |
| 82 | // Mark as completed if the store address, city and postcode are set. We don't need to check the country because it's set by default. |
| 83 | return get_option( 'woocommerce_store_address', '' ) !== '' && get_option( 'woocommerce_store_city', '' ) !== '' && |
| 84 | get_option( 'woocommerce_store_postcode', '' ) !== ''; |
| 85 | } |
| 86 | } |
| 87 |