Skip to content

Commit

Permalink
OBW: recommend either WCS or ShipStation (based on location) for labe…
Browse files Browse the repository at this point in the history
…l printing on shipping step.
  • Loading branch information
jeffstieler committed Aug 30, 2018
1 parent 2a24391 commit fde57ab
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 5 deletions.
21 changes: 16 additions & 5 deletions assets/css/wc-setup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1249,13 +1249,13 @@ p.jetpack-terms {
border: 1px solid #ebebeb;
border-radius: 4px;
padding: 2.5em;
}

li {
list-style: none;
.wc-setup-content .recommended-item {
list-style: none;

&:last-child label {
margin-bottom: 0; // Avoid extra space at the end of the list.
}
&:last-child label {
margin-bottom: 0; // Avoid extra space at the end of the list.
}

label {
Expand Down Expand Up @@ -1296,6 +1296,17 @@ p.jetpack-terms {
height: 2em;
padding: ( 3.5em - 2em ) / 2;
}

&.recommended-item-icon-woocommerce_services {
background-color: #f0f0f0;
max-height: 1.5em;
padding: 1.3em .7em;
}

&.recommended-item-icon-shipstation {
background-color: #f0f0f0;
padding: .3em;
}
}

.recommended-item-description-container {
Expand Down
Binary file added assets/images/obw-shipstation-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/obw-woocommerce-services-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions includes/admin/class-wc-admin-setup-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,35 @@ public function wc_setup_shipping() {
</ul>
<?php endif; ?>

<ul>
<?php
if ( $this->is_wcs_shipping_labels_supported_country( $country_code ) ) :
$this->display_recommended_item( array(
'type' => 'woocommerce_services',
'title' => __( 'Print shipping labels at home', 'woocommerce' ),
'description' => __( 'We recommend WooCommerce Services & Jetpack. These plugins will save you time at the Post Office by enabling you to print your shipping labels at home.', 'woocommerce' ),
'img_url' => WC()->plugin_url() . '/assets/images/obw-woocommerce-services-icon.png',
'img_alt' => __( 'WooCommerce Services icon', 'woocommerce' ),
'plugins' => $this->get_wcs_requisite_plugins(),
) );
elseif ( $this->is_shipstation_supported_country( $country_code ) ) :
$this->display_recommended_item( array(
'type' => 'shipstation',
'title' => __( 'Print shipping labels at home', 'woocommerce' ),
'description' => __( 'We recommend using ShipStation to save time at the Post Office by printing your shipping labels at home. Try ShipStation free for 30 days.', 'woocommerce' ),
'img_url' => WC()->plugin_url() . '/assets/images/obw-shipstation-icon.png',
'img_alt' => __( 'ShipStation icon', 'woocommerce' ),
'plugins' => array(
array(
'name' => __( 'ShipStation', 'woocommerce' ),
'slug' => 'woocommerce-shipstation',
),
),
) );
endif;
?>
</ul>

<div class="wc-setup-shipping-units">
<div class="wc-setup-shipping-unit">
<p>
Expand Down Expand Up @@ -1219,6 +1248,32 @@ protected function is_eway_payments_supported_country( $country_code ) {
return in_array( $country_code, $supported_countries, true );
}

/**
* Is ShipStation country supported
*
* @param string $country_code Country code.
*/
protected function is_shipstation_supported_country( $country_code ) {
$supported_countries = array(
'AU', // Australia.
'CA', // Canada.
'GB', // United Kingdom.
);
return in_array( $country_code, $supported_countries, true );
}

/**
* Is WooCommerce Services shipping label country supported
*
* @param string $country_code Country code.
*/
protected function is_wcs_shipping_labels_supported_country( $country_code ) {
$supported_countries = array(
'US', // United States.
);
return in_array( $country_code, $supported_countries, true );
}

/**
* Helper method to retrieve the current user's email address.
*
Expand Down

0 comments on commit fde57ab

Please sign in to comment.