diff --git a/plugins/woocommerce/assets/css/admin.scss b/plugins/woocommerce/assets/css/admin.scss index 1de1eb48349b..2adf05f9e64e 100644 --- a/plugins/woocommerce/assets/css/admin.scss +++ b/plugins/woocommerce/assets/css/admin.scss @@ -366,6 +366,17 @@ color: #fff; } + .addons-button-promoted { + float: right; + width: auto; + padding: 0 20px; + margin-top: 0; + } + + .addons-button-promoted:hover { + opacity: 0.8; + } + .addons-button-expandable { display: inline-block; padding: 0 16px; @@ -504,6 +515,10 @@ padding: 0; vertical-align: top; + &.addons-full-width { + max-width: 100%; + } + @media only screen and ( max-width: 768px ) { max-width: none; width: 100%; @@ -567,6 +582,35 @@ color: #1d2327; // Gray / Gray 90 } + &.featured, + &.promoted { + + .label { + align-items: center; + border-radius: 2px; + background: #dcdcde; + display: flex; + flex-direction: row; + height: 20px; + justify-content: flex-end; + margin-bottom: 8px; + max-width: 52px; + padding: 3px 12px; + top: 28px; + right: 24px; + text-align: center; + + &.promoted { + float: right; + max-width: 58px; + } + } + + h2 { + color: #2c3338; + } + } + p { color: #2c3338; font-size: 14px; @@ -670,6 +714,18 @@ } } + .product-footer-promoted { + align-items: flex-end; + display: flex; + justify-content: space-between; + padding: 24px; + + .icon img { + border-radius: 4px; + width: 80px; + } + } + .addons-buttons-banner { display: flex; flex-direction: row; diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-addons.php b/plugins/woocommerce/includes/admin/class-wc-admin-addons.php index 6747fbabe928..526e45b6b8ce 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-addons.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-addons.php @@ -26,7 +26,7 @@ class WC_Admin_Addons { * @return array of objects */ public static function get_featured() { - $featured = get_transient( 'wc_addons_featured' ); + $featured = get_transient( 'wc_addons_featured_2' ); if ( false === $featured ) { $headers = array(); $auth = WC_Helper_Options::get( 'auth' ); @@ -46,7 +46,7 @@ public static function get_featured() { if ( ! is_wp_error( $raw_featured ) ) { $featured = json_decode( wp_remote_retrieve_body( $raw_featured ) ); if ( $featured ) { - set_transient( 'wc_addons_featured', $featured, DAY_IN_SECONDS ); + set_transient( 'wc_addons_featured_2', $featured, DAY_IN_SECONDS ); } } } @@ -891,6 +891,7 @@ class="addons-button " * Output HTML for a promotion action. * * @param array $action Array of action properties. + * * @return void */ public static function output_promotion_action( array $action ) { @@ -1056,7 +1057,7 @@ public static function get_star_class( $rating, $index ) { if ( $rating >= $index ) { // Rating more that current star to show. return 'fill'; - } else if ( + } elseif ( abs( $index - 1 - floor( $rating ) ) < 0.0000001 && 0 < ( $rating - floor( $rating ) ) ) { @@ -1206,6 +1207,15 @@ public static function map_product_card_data( $data ) { if ( null === $mapped->reviews_count ) { $mapped->reviews_count = $data->reviewsCount ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase } + // Featured & Promoted product card. + // Label. + $mapped->label = $data->label ?? null; + // Primary color. + $mapped->primary_color = $data->primary_color ?? null; + // Text color. + $mapped->text_color = $data->text_color ?? null; + // Button text. + $mapped->button = $data->button ?? null; return $mapped; } @@ -1234,25 +1244,69 @@ public static function render_product_card( $data, $block_type = null ) { if ( 'banner' === $block_type ) { $product_details_classes .= ' addon-product-banner-details'; } - ?> + + if ( isset( $mapped->label ) && 'promoted' === $mapped->label ) { + $product_details_classes .= ' promoted'; + } elseif ( isset( $mapped->label ) && 'featured' === $mapped->label ) { + $product_details_classes .= ' featured'; + } + + if ( 'promoted' === $mapped->label + && ! empty( $mapped->primary_color ) + && ! empty( $mapped->text_color ) + && ! empty( $mapped->button ) ) { + // Promoted product card. + ?> +
  • +
    + + +

    title ); ?>

    +
    +

    description ); ?>

    +
    + +
  • +
  • + label ) && 'featured' === $mapped->label ) { ?> + +

    title ); ?>

    vendor_name ) && ! empty( $mapped->vendor_url ) ) : ?>
    %2$s', - esc_url_raw( $mapped->vendor_url ), - esc_html( $mapped->vendor_name ) - ) - ); + $vendor_url = add_query_arg( + array( + 'utm_source' => 'extensionsscreen', + 'utm_medium' => 'product', + 'utm_campaign' => 'wcaddons', + 'utm_content' => 'devpartner', + ), + $mapped->vendor_url + ); + + printf( + /* translators: %s vendor link */ + esc_html__( 'Developed by %s', 'woocommerce' ), + sprintf( + '%2$s', + esc_url_raw( $vendor_url ), + esc_html( $mapped->vendor_name ) + ) + ); ?>
    @@ -1303,6 +1357,7 @@ public static function render_product_card( $data, $block_type = null ) {
  • - slug ? 'current' : ''; ?>" continue; } } + + WC_Admin_Addons::render_product_card( $addon ); ?> -