Skip to content

Commit 080ac28

Browse files
authored
Merge pull request #222 from moderntribe/chore/SITE-200/shipping-card
chore: Revising shipping card look and footer
2 parents 2a0714c + c8582e9 commit 080ac28

File tree

2 files changed

+59
-98
lines changed

2 files changed

+59
-98
lines changed

plugins/wme-sitebuilder/wme-sitebuilder/Cards/Shipping.php

Lines changed: 37 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ public function __construct( ShippingPlugins $shipping_plugins ) {
3838
* @return array
3939
*/
4040
public function props() {
41+
$button_props = [
42+
'usps' => [
43+
'label' => __( 'Add USPS', 'wme-sitebuilder' ),
44+
'backgroundColor' => '#004B87',
45+
// TODO: Redirect user to an action that installs and activates the plugin.
46+
'href' => admin_url( 'admin.php?page=wc-settings&tab=shipping' ),
47+
]
48+
];
49+
4150
// Flat rate is built-in to WooCommerce.
4251
$rows = [
4352
[
@@ -48,6 +57,17 @@ public function props() {
4857
'intro' => __( 'Charge a fixed rate of your choosing for shipping.', 'wme-sitebuilder' ),
4958
'url' => admin_url( 'admin.php?page=wc-settings&tab=shipping' ),
5059
],
60+
[
61+
'id' => 'usps',
62+
'type' => 'task',
63+
'taskCta' => __( 'USPS Settings', 'wme-sitebuilder' ),
64+
'title' => __( 'USPS', 'wme-sitebuilder' ),
65+
'intro' => __( 'Shipping rates based on address and cart content through USPS.', 'wme-sitebuilder' ),
66+
'disabled' => false,
67+
'disableText' => '',
68+
'url' => $this->plugins->isUspsActive() ? admin_url( 'admin.php?page=wc-settings&tab=shipping&section=elex_shipping_usps' ) : null,
69+
'button' => ! $this->plugins->isUspsActive() ? $button_props['usps'] : null,
70+
],
5171
];
5272

5373
// Check our supported shipping plugins.
@@ -59,103 +79,33 @@ public function props() {
5979
$rows[] = $plugin['card'];
6080
}
6181

62-
// If there are additional options, make wizard available.
63-
if ( 1 === count( $rows ) && 0 < count( $this->plugins->getPlugins() ) ) {
64-
$rows[] = [
65-
'id' => 'shipping-wizard',
66-
'type' => 'button',
67-
'wizardHash' => '/wizard/shipping',
68-
'title' => __( 'Add another way to ship', 'wme-sitebuilder' ),
69-
];
70-
}
71-
7282
return [
7383
'id' => 'shipping-configuration',
7484
'title' => __( 'Configure shipping', 'wme-sitebuilder' ),
7585
'intro' => __( 'Offer flat rate shipping and/or set up ShipStation to offer multiple rates.', 'wme-sitebuilder' ),
7686
'completed' => false,
7787
'rows' => $rows,
7888
'footer' => [
79-
'collapsible' => true,
80-
'collapsibleLabel' => __( 'Learn more about Shipping', 'wme-sitebuilder' ),
81-
'rows' => [
89+
'collapsible' => false,
90+
'rows' => [
8291
[
83-
'type' => 'learn-types',
84-
'title' => 'Is this needed here?',
85-
'overline' => __( '3 Minutes', 'wme-sitebuilder' ),
86-
'headline' => __( 'Understanding Flat Rate Shipping in Storebuilder', 'wme-sitebuilder' ),
87-
'videoData' => [
88-
'placeholderImage' => 'setup-shipping-poster.png',
89-
'ariaLabel' => __( 'Click to play video', 'wme-sitebuilder' ),
90-
'src' => 'https://www.youtube.com/embed/EXMe2i7OSQM',
91-
'description' => __( 'When setting up shipping in StoreBuilder, there are three concepts to understand: Flat Rate Shipping, Shipping Zones, and Shipping Classes. This video describes each and how they interact to ensure customers are charged correctly to ship their purchases.', 'wme-sitebuilder' ),
92-
]
92+
'type' => 'links',
93+
'title' => __( 'Need help with shipping?', 'wme-sitebuilder' ),
94+
'links' => $this->footer_messages(),
9395
],
94-
[
95-
'type' => 'columns',
96-
'gridColumns' => 3,
97-
'columns' => [
98-
[
99-
'heading' => __( 'Shipping Zones', 'wme-sitebuilder' ),
100-
'list' => [
101-
[
102-
'icon' => 'Add',
103-
'title' => __( 'Set up Shipping Zones', 'wme-sitebuilder' ),
104-
'url' => admin_url( 'admin.php?page=wc-settings&tab=shipping' ),
105-
'target' => '_self',
106-
],
107-
[
108-
'icon' => 'LocalLibrary',
109-
'title' => __( 'WooCommerce: Shipping Zones Docs', 'wme-sitebuilder' ),
110-
'url' => 'https://woocommerce.com/document/setting-up-shipping-zones/',
111-
'target' => '_blank',
112-
],
113-
],
114-
],
115-
[
116-
'heading' => __( 'Shipping Classes', 'wme-sitebuilder' ),
117-
'list' => [
118-
[
119-
'icon' => 'Add',
120-
'title' => __( 'Set up Shipping Classes', 'wme-sitebuilder' ),
121-
'url' => admin_url( 'admin.php?page=wc-settings&tab=shipping&section=classes' ),
122-
'target' => '_self',
123-
],
124-
[
125-
'icon' => 'School',
126-
'title' => __( 'Tutorial: Shipping Classes', 'wme-sitebuilder' ),
127-
'url' => 'wp101:woocommerce-shipping-classes',
128-
'target' => '_self',
129-
],
130-
[
131-
'icon' => 'LocalLibrary',
132-
'title' => __( 'WooCommerce: Shipping Classes Docs', 'wme-sitebuilder' ),
133-
'url' => 'https://woocommerce.com/document/product-shipping-classes/',
134-
'target' => '_blank',
135-
],
136-
],
137-
],
138-
[
139-
'heading' => __( 'Shipping Calculations', 'wme-sitebuilder' ),
140-
'list' => [
141-
[
142-
'icon' => 'Add',
143-
'title' => __( 'Set Flat Rate shipping calculations', 'wme-sitebuilder' ),
144-
'url' => admin_url( 'admin.php?page=wc-settings&tab=shipping&section=options' ),
145-
'target' => '_blank',
146-
],
147-
[
148-
'icon' => 'School',
149-
'title' => __( 'Tutorial: Flat Rate Shipping', 'wme-sitebuilder' ),
150-
'url' => 'wp101:woocommerce-flat-rate-shipping',
151-
'target' => '_self',
152-
],
153-
],
154-
],
155-
]
156-
]
157-
],
96+
]
15897
],
15998
];
16099
}
100+
101+
/**
102+
* Get card footer messages.
103+
*
104+
* @return array[]
105+
*/
106+
protected function footer_messages() {
107+
return [
108+
$this->plugins->card_footer_props()
109+
];
110+
}
161111
}

plugins/wme-sitebuilder/wme-sitebuilder/Plugins/Shipping.php

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,6 @@ public function __construct() {
2424
*/
2525
$this->plugins['elex-usps-shipping-method'] = [
2626
'active' => (bool) $this->isPluginActive( 'elex-usps-shipping-method/usps-woocommerce-shipping.php' ),
27-
'card' => [
28-
'id' => 'usps',
29-
'type' => 'task',
30-
'taskCta' => __( 'USPS Settings', 'wme-sitebuilder' ),
31-
'title' => __( 'USPS', 'wme-sitebuilder' ),
32-
'intro' => __( 'Shipping rates based on address and cart content through USPS.', 'wme-sitebuilder' ),
33-
'icon' => 'setup-icon-usps.png',
34-
'disabled' => false,
35-
'disableText' => '',
36-
'url' => admin_url( 'admin.php?page=wc-settings&tab=shipping&section=elex_shipping_usps' ),
37-
],
3827
];
3928
}
4029

@@ -46,4 +35,26 @@ public function __construct() {
4635
public function getPlugins() {
4736
return $this->plugins;
4837
}
38+
39+
/**
40+
* Is USPS active?
41+
*
42+
* @return bool
43+
*/
44+
public function isUspsActive() {
45+
return $this->plugins['elex-usps-shipping-method']['active'];
46+
}
47+
48+
/**
49+
* Get properties for footer message.
50+
*
51+
* @return array
52+
*/
53+
public function card_footer_props() {
54+
// TODO: Temporary until we have the real links.
55+
return [
56+
'label' => __( 'Help with USPS', 'wme-sitebuilder' ),
57+
'href' => '#',
58+
];
59+
}
4960
}

0 commit comments

Comments
 (0)