From 5c81b4f5ea3ff9a84a8b5dd2d6658281dddcf088 Mon Sep 17 00:00:00 2001 From: Timur Gogolev Date: Tue, 5 Oct 2021 13:27:56 +0300 Subject: [PATCH 01/34] Remove the current addons implementation --- assets/css/admin.scss | 360 --------------- includes/admin/class-wc-admin-addons.php | 435 +----------------- .../admin/views/html-admin-page-addons.php | 4 +- 3 files changed, 16 insertions(+), 783 deletions(-) diff --git a/assets/css/admin.scss b/assets/css/admin.scss index 47da6765b34..396a4b619fc 100644 --- a/assets/css/admin.scss +++ b/assets/css/admin.scss @@ -243,185 +243,6 @@ width: 124px; } - .addons-banner-block-item-icon, - .addons-column-block-item-icon { - align-items: center; - display: flex; - justify-content: center; - } - - .addons-banner-block, - .addons-wcs-banner-block { - background: #fff; - border: 1px solid #ddd; - margin: 0 0 1em 0; - padding: 2em 2em 1em; - } - - .addons-banner-block img { - height: 62px; - } - - .addons-banner-block p { - margin: 0 0 20px; - } - - .addons-banner-block-items { - display: flex; - flex-direction: row; - flex-wrap: wrap; - justify-content: space-around; - margin: 0 -10px 0 -10px; - } - - .addons-banner-block-item { - border: 1px solid #e6e6e6; - border-radius: 3px; - flex: 1; - margin: 1em; - min-width: 200px; - width: 30%; - } - - .addons-banner-block-item-icon { - background: #f7f7f7; - height: 143px; - } - - .addons-banner-block-item-content { - display: flex; - flex-direction: column; - height: 184px; - justify-content: space-between; - padding: 24px; - } - - .addons-banner-block-item-content h3 { - margin-top: 0; - } - - .addons-banner-block-item-content p { - margin: 0 0 auto; - } - - .addons-wcs-banner-block { - display: flex; - align-items: center; - } - - .addons-promotion-block { - display: flex; - padding: 20px; - - .addons-img { - height: auto; - width: 200px; - } - } - - .addons-wcs-banner-block-image { - background: #f7f7f7; - border: 1px solid #e6e6e6; - margin-right: 2em; - padding: 4em; - max-width: 200px; - - .addons-img { - max-height: 86px; - max-width: 97px; - } - - &.is-full-image { - padding: 0; - background: none; - border: none; - - .addons-img { - max-height: 100%; - max-width: 100%; - } - } - } - - .addons-promotion-block-content { - display: flex; - flex-direction: column; - margin-left: 24px; - } - - .addons-promotion-block-description { - margin-bottom: 20px; - } - - .addons-promotion-block-title { - margin: 0 0 16px; - padding: 0; - } - - .addons-promotion-block-buttons { - margin-top: auto; - - .addons-button { - margin-right: 8px; - - &:last-child { - margin-right: 0; - } - } - } - - .addons-shipping-methods .addons-wcs-banner-block { - margin-left: 0; - margin-right: 0; - margin-top: 1em; - } - - .addons-wcs-banner-block-content { - display: flex; - flex-direction: column; - justify-content: space-around; - align-self: stretch; - padding: 1em 0; - - h1 { - padding-bottom: 0; - } - - p { - margin-bottom: 0; - } - - .wcs-logos-container { - display: flex; - align-items: center; - flex-direction: row; - justify-content: center; - - @media screen and (min-width: 500px) { - justify-content: left; - } - - li { - margin-right: 8px; - - &:last-child { - margin-right: 0; - } - } - } - - .wcs-service-logo { - max-width: 45px; - } - } - - .addons-column-section { - display: flex; - flex-direction: row; - flex-wrap: wrap; - justify-content: space-around; - } - .addons-column { flex: 1; width: 50%; @@ -432,90 +253,6 @@ margin-right: 0; } - .addons-small-light-block, - .addons-small-dark-block, - .addons-column-block { - box-sizing: border-box; - border: 1px solid #ddd; - margin: 0 0 1em; - padding: 20px; - } - - .addons-column-block img { - max-height: 50px; - max-width: 50px; - } - - .addons-small-light-block, - .addons-column-block { - background: #fff; - } - - .addons-column-block-left { - float: left; - } - - .addons-column-block-right { - float: right; - } - - .addons-column-block-item { - border-top: 2px solid #f9f9f9; - flex-direction: row; - flex-wrap: wrap; - justify-content: space-between; - margin: 0 -20px; - padding: 20px; - } - - .addons-column-block-item-icon { - background: #f7f7f7; - border: 1px solid #e6e6e6; - height: 100px; - margin: 0 10px 10px 0; - width: 100px; - } - - .addons-column-block-item-content { - display: flex; - flex: 1; - flex-wrap: wrap; - height: 20%; - justify-content: space-between; - min-width: 200px; - } - - .addons-column-block-item-content h2 { - float: left; - margin-top: 8px; - } - - .addons-column-block-item-content a { - float: right; - } - - .addons-column-block-item-content p { - float: left; - } - - .addons-banner-block-item, - .addons-column-block-item { - display: none; - } - - .addons-banner-block-item:nth-child(-n + 3) { - display: block; - } - - .addons-column-block-item:nth-of-type(-n + 3) { - display: flex; - } - - .addons-small-dark-block { - background-color: #54687d; - text-align: center; - } - .addons-small-dark-items { display: flex; flex-wrap: wrap; @@ -526,14 +263,6 @@ margin: 0 0 20px; } - .addons-small-dark-block h1 { - color: #fff; - } - - .addons-small-dark-block p { - color: #fafafa; - } - .addons-small-dark-item-icon img { height: 30px; } @@ -542,40 +271,6 @@ margin: 28px auto 0; } - .addons-small-light-block { - display: flex; - flex-wrap: wrap; - } - - .addons-small-light-block h1 { - margin-top: -12px; - } - - .addons-small-light-block p { - margin-top: 0; - } - - .addons-small-light-block img { - height: 225px; - margin: 0 0 0 -20px; - } - - .addons-small-light-block-content { - display: flex; - flex: 1 1 100px; - flex-direction: column; - justify-content: space-around; - } - - .addons-small-light-block-buttons { - display: flex; - justify-content: space-between; - } - - .addons-small-light-block-content a { - width: 48%; - } - .addons-button-solid { background-color: #674399; color: #fff; @@ -645,14 +340,6 @@ .addons-small-dark-item { width: 100%; } - - .addons-column-block-item-icon { - background: none; - border: none; - height: 75px; - margin: 0 10px 10px 0; - width: 75px; - } } .marketplace-content-wrapper { @@ -2954,30 +2641,6 @@ ul.wc_coupon_list_block { float: right; } } - - .wc-addons-wrap { - - .addons-promotion-block { - flex-direction: column; - padding: 24px; - - .addons-img { - height: auto; - width: 100%; - max-width: 240px; - margin: 0 auto 20px; - } - } - - .addons-promotion-block-content { - display: block; - margin-left: 0; - } - - .addons-promotion-block-title { - margin-top: 4px; - } - } } .column-customer_message .note-on { @@ -6755,29 +6418,6 @@ table.bar_chart { .woocommerce_options_panel p.form-field { padding: 5px 20px !important; } - - .addons-wcs-banner-block { - flex-direction: column; - } - - .wc-addons-wrap { - - .addons-wcs-banner-block { - padding: 40px; - } - - .addons-wcs-banner-block-image { - padding: 1em; - text-align: center; - width: 100%; - padding: 2em 0; - margin: 0; - - .addons-img { - margin: 0; - } - } - } } /** diff --git a/includes/admin/class-wc-admin-addons.php b/includes/admin/class-wc-admin-addons.php index 82a96a401e9..2eb5d8480a8 100644 --- a/includes/admin/class-wc-admin-addons.php +++ b/includes/admin/class-wc-admin-addons.php @@ -20,10 +20,10 @@ class WC_Admin_Addons { /** * Get featured for the addons screen * - * @return array of objects + * @return void */ - public static function get_featured() { - $featured = get_transient( 'wc_addons_featured' ); + public static function render_featured() { + $featured = false; // get_transient( 'wc_addons_featured' ); // TODO: revert. if ( false === $featured ) { $headers = array(); $auth = WC_Helper_Options::get( 'auth' ); @@ -32,8 +32,9 @@ class WC_Admin_Addons { $headers['Authorization'] = 'Bearer ' . $auth['access_token']; } + // TODO: replace with WC.com, leave 2.0. $raw_featured = wp_safe_remote_get( - 'https://woocommerce.com/wp-json/wccom-extensions/1.0/featured', + 'https://woocommerce.test/wp-json/wccom-extensions/2.0/featured', array( 'headers' => $headers, 'user-agent' => 'WooCommerce Addons Page', @@ -49,8 +50,7 @@ class WC_Admin_Addons { } if ( is_object( $featured ) ) { - self::output_featured_sections( $featured->sections ); - return $featured; + self::output_featured( $featured ); } } @@ -206,423 +206,18 @@ class WC_Admin_Addons { } /** - * Handles the outputting of a banner block. + * Handles the outputting of featured page * - * @param object $block Banner data. + * @param array $blocks Featured page's blocks. */ - public static function output_banner_block( $block ) { - ?> -
-

title ); ?>

-

description ); ?>

-
- items as $item ) : ?> - -
-
- -
-
-

title ); ?>

-

description ); ?>

- href, - $item->button, - 'addons-button-solid', - $item->plugin - ); - ?> -
-
- - -
-
- container ) && 'column_container_start' === $block->container ) { - ?> -
- module ) { - ?> -
- -
- container ) && 'column_container_end' === $block->container ) { - ?> -
- -
-

title ); ?>

-

description ); ?>

- items as $item ) : ?> - -
-
- -
-
-

title ); ?>

- href, - $item->button, - 'addons-button-solid', - $item->plugin - ); - ?> -

description ); ?>

-
-
- - -
- - -
- -
-

title ); ?>

-

description ); ?>

-
- buttons as $button ) : ?> - href, - $button->text, - 'addons-button-solid' - ); - ?> - -
-
-
- -
-

title ); ?>

-

description ); ?>

-
- items as $item ) : ?> -
- image ) ) : ?> -
- -
- - href, - $item->button, - 'addons-button-outline-white' - ); - ?> -
- -
-
- 'woocommerce-services', - ) - ), - 'install-addon_woocommerce-services' - ); - - $defaults = array( - 'image' => WC()->plugin_url() . '/assets/images/wcs-extensions-banner-3x.jpg', - 'image_alt' => __( 'WooCommerce Shipping', 'woocommerce' ), - 'title' => __( 'Save time and money with WooCommerce Shipping', 'woocommerce' ), - 'description' => __( 'Print discounted USPS and DHL labels straight from your WooCommerce dashboard and save on shipping.', 'woocommerce' ), - 'button' => __( 'Free - Install now', 'woocommerce' ), - 'href' => $button_url, - 'logos' => array(), - ); - - switch ( $location['country'] ) { - case 'US': - $local_defaults = array( - 'logos' => array_merge( - $defaults['logos'], - array( - array( - 'link' => WC()->plugin_url() . '/assets/images/wcs-usps-logo.png', - 'alt' => 'USPS logo', - ), - array( - 'link' => WC()->plugin_url() . '/assets/images/wcs-dhlexpress-logo.png', - 'alt' => 'DHL Express logo', - ), - ) - ), - ); - break; - default: - $local_defaults = array(); - } - - $block_data = array_merge( $defaults, $local_defaults, $block ); - ?> -
-
- <?php echo esc_attr( $block_data['image_alt'] ); ?> -
-
-

-

-
    - -
  • - -
  • - -
- -
-
- 'woocommerce-payments', - ) - ), - 'install-addon_woocommerce-payments' - ); - - $defaults = array( - 'image' => WC()->plugin_url() . '/assets/images/wcpayments-icon-secure.png', - 'image_alt' => __( 'WooCommerce Payments', 'woocommerce' ), - 'title' => __( 'Payments made simple, with no monthly fees — exclusively for WooCommerce stores.', 'woocommerce' ), - 'description' => __( 'Securely accept cards in your store. See payments, track cash flow into your bank account, and stay on top of disputes – right from your dashboard.', 'woocommerce' ), - 'button' => __( 'Free - Install now', 'woocommerce' ), - 'href' => $button_url, - 'logos' => array(), - ); - - $block_data = array_merge( $defaults, $block ); - ?> -
-
- <?php echo esc_attr( $block_data['image_alt'] ); ?> -
-
-

-

- -
-
- geowhitelist ) ) { - $section_object->geowhitelist = explode( ',', $section_object->geowhitelist ); - } - - if ( ! empty( $section_object->geoblacklist ) ) { - $section_object->geoblacklist = explode( ',', $section_object->geoblacklist ); - } - - if ( ! self::show_extension( $section_object ) ) { - return; - } - - ?> -
- <?php echo esc_attr( $section['image_alt'] ); ?> -
-

-
- -
-
- -
-
-
- module ) { - case 'banner_block': - self::output_banner_block( $section ); + private static function output_featured( $blocks ) { + foreach ( $blocks as $block ) { + switch ( $block->type ) { + case 'group': + // TODO: break; - case 'column_start': - self::output_column( $section ); - break; - case 'column_end': - self::output_column( $section ); - break; - case 'column_block': - self::output_column_block( $section ); - break; - case 'small_light_block': - self::output_small_light_block( $section ); - break; - case 'small_dark_block': - self::output_small_dark_block( $section ); - break; - case 'wcs_banner_block': - self::output_wcs_banner_block( (array) $section ); - break; - case 'wcpay_banner_block': - self::output_wcpay_banner_block( (array) $section ); - break; - case 'promotion_block': - self::output_promotion_block( (array) $section ); + case 'banner': + // TODO: break; } } diff --git a/includes/admin/views/html-admin-page-addons.php b/includes/admin/views/html-admin-page-addons.php index ceaf5a380b6..cc464c2e2ec 100644 --- a/includes/admin/views/html-admin-page-addons.php +++ b/includes/admin/views/html-admin-page-addons.php @@ -76,9 +76,7 @@ $current_section_name = __( 'Browse Categories', 'woocommerce' ); From 916a13b6c68f7d610b605be33e8bcdf68dd3cc6f Mon Sep 17 00:00:00 2001 From: Timur Gogolev Date: Wed, 29 Sep 2021 16:23:04 +0300 Subject: [PATCH 02/34] Add stars and reviews number --- assets/css/admin.scss | 32 +++++++++++++++++++ assets/images/icons/star.svg | 13 ++++++++ .../admin/views/html-admin-page-addons.php | 24 ++++++++++---- 3 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 assets/images/icons/star.svg diff --git a/assets/css/admin.scss b/assets/css/admin.scss index 396a4b619fc..d3169270371 100644 --- a/assets/css/admin.scss +++ b/assets/css/admin.scss @@ -421,7 +421,11 @@ } .product-footer { + align-items: center; border-top: 1px solid #dcdcde; + display: flex; + flex-direction: row; + justify-content: space-between; padding: 24px; .price { @@ -429,11 +433,39 @@ color: #1d2327; } + .price-suffix { + color: #646970; /* Gray 50 */ + } + + .product-reviews-block { + display: flex; + flex-direction: row; + margin-top: 4px; + + .product-rating-star { + background: url(../images/icons/star.svg) no-repeat; + background-size: contain; + height: 16px; + margin: 4px 4px 4px 0; + width: 17px; + } + + .product-reviews-count { + color: #646970; /* Gray 50 */ + font-size: 12px; + font-family: sans-serif; + line-height: 24px; + letter-spacing: -0.154px; + margin-left: 4px; + } + } + .button { background-color: #fff; border-color: #007cba; color: #007cba; float: right; + height: 22px; } } } diff --git a/assets/images/icons/star.svg b/assets/images/icons/star.svg new file mode 100644 index 00000000000..9f550f87964 --- /dev/null +++ b/assets/images/icons/star.svg @@ -0,0 +1,13 @@ + + + + diff --git a/includes/admin/views/html-admin-page-addons.php b/includes/admin/views/html-admin-page-addons.php index cc464c2e2ec..b70ccd18aab 100644 --- a/includes/admin/views/html-admin-page-addons.php +++ b/includes/admin/views/html-admin-page-addons.php @@ -125,12 +125,24 @@ $current_section_name = __( 'Browse Categories', 'woocommerce' );

excerpt ); ?>