DefaultShippingPartners.php
1 month ago
ShippingPartnerSuggestions.php
3 months ago
ShippingPartnerSuggestionsDataSourcePoller.php
1 year ago
DefaultShippingPartners.php
302 lines
| 1 | <?php declare( strict_types=1 ); |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Admin\Features\ShippingPartnerSuggestions; |
| 4 | |
| 5 | /** |
| 6 | * Default Shipping Partners |
| 7 | */ |
| 8 | class DefaultShippingPartners { |
| 9 | |
| 10 | /** |
| 11 | * Get default specs. |
| 12 | * |
| 13 | * @return array Default specs. |
| 14 | */ |
| 15 | public static function get_all() { |
| 16 | $asset_base_url = WC()->plugin_url() . '/assets/images/shipping_partners/'; |
| 17 | $column_layout_features = array( |
| 18 | array( |
| 19 | 'icon' => $asset_base_url . 'timer.svg', |
| 20 | 'title' => __( 'Save time', 'woocommerce' ), |
| 21 | 'description' => __( |
| 22 | 'Automatically import order information to quickly print your labels.', |
| 23 | 'woocommerce' |
| 24 | ), |
| 25 | ), |
| 26 | array( |
| 27 | 'icon' => $asset_base_url . 'discount.svg', |
| 28 | 'title' => __( 'Save money', 'woocommerce' ), |
| 29 | 'description' => __( |
| 30 | 'Shop for the best shipping rates, and access pre-negotiated discounted rates.', |
| 31 | 'woocommerce' |
| 32 | ), |
| 33 | ), |
| 34 | array( |
| 35 | 'icon' => $asset_base_url . 'star.svg', |
| 36 | 'title' => __( 'Wow your shoppers', 'woocommerce' ), |
| 37 | 'description' => __( |
| 38 | 'Keep your customers informed with tracking notifications.', |
| 39 | 'woocommerce' |
| 40 | ), |
| 41 | ), |
| 42 | ); |
| 43 | |
| 44 | $check_icon = $asset_base_url . 'check.svg'; |
| 45 | |
| 46 | return array( |
| 47 | array( |
| 48 | 'id' => 'woocommerce-shipstation-integration', |
| 49 | 'name' => 'ShipStation', |
| 50 | 'slug' => 'woocommerce-shipstation-integration', |
| 51 | 'description' => __( 'Powerful yet easy-to-use solution:', 'woocommerce' ), |
| 52 | 'layout_column' => array( |
| 53 | 'image' => $asset_base_url . 'shipstation-column.svg', |
| 54 | 'features' => $column_layout_features, |
| 55 | ), |
| 56 | 'layout_row' => array( |
| 57 | 'image' => $asset_base_url . 'shipstation-row.svg', |
| 58 | 'features' => array( |
| 59 | array( |
| 60 | 'icon' => $check_icon, |
| 61 | 'description' => __( |
| 62 | 'Discounted labels from top global carriers', |
| 63 | 'woocommerce' |
| 64 | ), |
| 65 | ), |
| 66 | array( |
| 67 | 'icon' => $check_icon, |
| 68 | 'description' => __( |
| 69 | 'Sync all your selling channels in one place', |
| 70 | 'woocommerce' |
| 71 | ), |
| 72 | ), |
| 73 | array( |
| 74 | 'icon' => $check_icon, |
| 75 | 'description' => __( 'Advanced automated workflows and customs', 'woocommerce' ), |
| 76 | ), |
| 77 | array( |
| 78 | 'icon' => $check_icon, |
| 79 | 'description' => __( 'Instantly send tracking to your customers', 'woocommerce' ), |
| 80 | ), |
| 81 | array( |
| 82 | 'icon' => $check_icon, |
| 83 | 'description' => __( '30-day free trial', 'woocommerce' ), |
| 84 | ), |
| 85 | ), |
| 86 | ), |
| 87 | 'learn_more_link' => 'https://wordpress.org/plugins/woocommerce-shipstation-integration/', |
| 88 | 'is_visible' => array( |
| 89 | self::get_rules_for_countries( array( 'US', 'AU', 'NZ', 'CA', 'GB' ) ), |
| 90 | ), |
| 91 | 'available_layouts' => array( 'row', 'column' ), |
| 92 | 'countries_where_primary' => array( 'NZ', 'CA', 'GB' ), |
| 93 | ), |
| 94 | array( |
| 95 | 'id' => 'skydropx-cotizador-y-envios', |
| 96 | 'name' => 'Skydropx', |
| 97 | 'slug' => 'skydropx-cotizador-y-envios', |
| 98 | 'layout_column' => array( |
| 99 | 'image' => $asset_base_url . 'skydropx-column.svg', |
| 100 | 'features' => $column_layout_features, |
| 101 | ), |
| 102 | 'description' => '', |
| 103 | 'learn_more_link' => 'https://wordpress.org/plugins/skydropx-cotizador-y-envios/', |
| 104 | 'is_visible' => array( |
| 105 | self::get_rules_for_countries( array() ), |
| 106 | // No countries eligible for SkydropX promotion at this time. |
| 107 | ), |
| 108 | 'available_layouts' => array( 'column' ), |
| 109 | 'countries_where_primary' => array(), |
| 110 | ), |
| 111 | array( |
| 112 | 'id' => 'envia', |
| 113 | 'name' => 'Envia', |
| 114 | 'slug' => '', |
| 115 | 'description' => '', |
| 116 | 'layout_column' => array( |
| 117 | 'image' => $asset_base_url . 'envia-column.svg', |
| 118 | 'features' => $column_layout_features, |
| 119 | ), |
| 120 | 'learn_more_link' => 'https://woocommerce.com/products/envia-shipping-and-fulfillment/', |
| 121 | 'is_visible' => array( |
| 122 | self::get_rules_for_countries( array( 'MX', 'CO', 'CL', 'AR', 'PE', 'BR', 'UY', 'GT' ) ), |
| 123 | ), |
| 124 | 'available_layouts' => array( 'column' ), |
| 125 | 'countries_where_primary' => array( 'MX', 'CO', 'CL', 'AR', 'PE', 'BR', 'UY', 'GT' ), |
| 126 | ), |
| 127 | array( |
| 128 | 'id' => 'easyship-woocommerce-shipping-rates', |
| 129 | 'name' => 'Easyship', |
| 130 | 'slug' => 'easyship-woocommerce-shipping-rates', |
| 131 | 'description' => __( 'Simplified shipping with: ', 'woocommerce' ), |
| 132 | 'layout_column' => array( |
| 133 | 'image' => $asset_base_url . 'easyship-column.svg', |
| 134 | 'features' => $column_layout_features, |
| 135 | ), |
| 136 | 'layout_row' => array( |
| 137 | 'image' => $asset_base_url . 'easyship-row.svg', |
| 138 | 'features' => array( |
| 139 | array( |
| 140 | 'icon' => $check_icon, |
| 141 | 'description' => __( 'Highly discounted shipping rates', 'woocommerce' ), |
| 142 | ), |
| 143 | array( |
| 144 | 'icon' => $check_icon, |
| 145 | 'description' => __( |
| 146 | 'Seamless order sync and label printing', |
| 147 | 'woocommerce' |
| 148 | ), |
| 149 | ), |
| 150 | array( |
| 151 | 'icon' => $check_icon, |
| 152 | 'description' => __( 'Branded tracking experience', 'woocommerce' ), |
| 153 | ), |
| 154 | array( |
| 155 | 'icon' => $check_icon, |
| 156 | 'description' => __( 'Built-in Tax & Duties paperwork', 'woocommerce' ), |
| 157 | ), |
| 158 | array( |
| 159 | 'icon' => $check_icon, |
| 160 | 'description' => __( 'Free Plan Available', 'woocommerce' ), |
| 161 | ), |
| 162 | ), |
| 163 | ), |
| 164 | 'learn_more_link' => 'https://woocommerce.com/products/easyship-shipping-rates/', |
| 165 | 'is_visible' => array( |
| 166 | self::get_rules_for_countries( array( 'SG', 'HK', 'AU', 'NZ' ) ), |
| 167 | ), |
| 168 | 'available_layouts' => array( 'row', 'column' ), |
| 169 | 'countries_where_primary' => array( 'SG', 'HK', 'AU' ), |
| 170 | ), |
| 171 | array( |
| 172 | 'id' => 'packlink-pro-shipping', |
| 173 | 'name' => 'Packlink', |
| 174 | 'slug' => 'packlink-pro-shipping', |
| 175 | 'description' => __( 'Optimize your full shipping process:', 'woocommerce' ), |
| 176 | 'layout_column' => array( |
| 177 | 'image' => $asset_base_url . 'packlink-column.svg', |
| 178 | 'features' => $column_layout_features, |
| 179 | ), |
| 180 | 'layout_row' => array( |
| 181 | 'image' => $asset_base_url . 'packlink-row.svg', |
| 182 | 'features' => array( |
| 183 | array( |
| 184 | 'icon' => $check_icon, |
| 185 | 'description' => __( |
| 186 | 'Automated, real-time order import', |
| 187 | 'woocommerce' |
| 188 | ), |
| 189 | ), |
| 190 | array( |
| 191 | 'icon' => $check_icon, |
| 192 | 'description' => __( |
| 193 | 'Direct access to leading carriers', |
| 194 | 'woocommerce' |
| 195 | ), |
| 196 | ), |
| 197 | array( |
| 198 | 'icon' => $check_icon, |
| 199 | 'description' => __( |
| 200 | 'Access competitive shipping prices', |
| 201 | 'woocommerce' |
| 202 | ), |
| 203 | ), |
| 204 | array( |
| 205 | 'icon' => $check_icon, |
| 206 | 'description' => __( 'Quickly bulk print labels', 'woocommerce' ), |
| 207 | ), |
| 208 | array( |
| 209 | 'icon' => $check_icon, |
| 210 | 'description' => __( 'Free shipping platform', 'woocommerce' ), |
| 211 | ), |
| 212 | ), |
| 213 | ), |
| 214 | 'learn_more_link' => 'https://wordpress.org/plugins/packlink-pro-shipping/', |
| 215 | 'is_visible' => array( |
| 216 | self::get_rules_for_countries( array( 'FR', 'DE', 'ES', 'IT', 'NL', 'AT', 'BE', 'IE', 'PT' ) ), |
| 217 | ), |
| 218 | 'available_layouts' => array( 'row', 'column' ), |
| 219 | 'countries_where_primary' => array( 'FR', 'DE', 'ES', 'IT', 'NL', 'AT', 'BE', 'IE', 'PT' ), |
| 220 | ), |
| 221 | array( |
| 222 | 'id' => 'woocommerce-shipping', |
| 223 | 'name' => 'WooCommerce Shipping', |
| 224 | 'slug' => 'woocommerce-shipping', |
| 225 | 'description' => __( 'Save time and money by printing your shipping labels right from your computer with WooCommerce Shipping. Try WooCommerce Shipping for free.', 'woocommerce' ), |
| 226 | 'layout_column' => array( |
| 227 | 'image' => $asset_base_url . 'wcs-column.svg', |
| 228 | 'features' => array( |
| 229 | array( |
| 230 | 'icon' => $asset_base_url . 'printer.svg', |
| 231 | 'title' => __( 'Buy postage when you need it', 'woocommerce' ), |
| 232 | 'description' => __( 'No need to wonder where that stampbook went.', 'woocommerce' ), |
| 233 | ), |
| 234 | array( |
| 235 | 'icon' => $asset_base_url . 'paper.svg', |
| 236 | 'title' => __( 'Print at home', 'woocommerce' ), |
| 237 | 'description' => __( 'Pick up an order, then just pay, print, package and post.', 'woocommerce' ), |
| 238 | ), |
| 239 | array( |
| 240 | 'icon' => $asset_base_url . 'discount.svg', |
| 241 | 'title' => __( 'Discounted rates', 'woocommerce' ), |
| 242 | 'description' => __( 'Access discounted shipping rates with USPS, UPS, and DHL.', 'woocommerce' ), |
| 243 | ), |
| 244 | ), |
| 245 | ), |
| 246 | 'layout_row' => array( |
| 247 | 'image' => $asset_base_url . 'wcs-row.svg', |
| 248 | 'image_label' => __( 'WooCommerce Shipping', 'woocommerce' ), |
| 249 | 'description' => __( 'Save time and money by managing shipping right from your WooCommerce dashboard.', 'woocommerce' ), |
| 250 | 'features' => array( |
| 251 | array( |
| 252 | 'icon' => $check_icon, |
| 253 | 'description' => __( 'Instantly save on USPS, UPS, FedEx and DHL Express labels.', 'woocommerce' ), |
| 254 | ), |
| 255 | array( |
| 256 | 'icon' => $check_icon, |
| 257 | 'description' => __( 'Access live rates across carriers to get the best prices for you and your customers.', 'woocommerce' ), |
| 258 | ), |
| 259 | array( |
| 260 | 'icon' => $check_icon, |
| 261 | 'description' => __( 'Keep customers happy and informed every step of the way.', 'woocommerce' ), |
| 262 | ), |
| 263 | array( |
| 264 | 'icon' => $check_icon, |
| 265 | 'description' => __( 'Free to install, with no markup or monthly fees.', 'woocommerce' ), |
| 266 | ), |
| 267 | ), |
| 268 | ), |
| 269 | 'learn_more_link' => 'https://woocommerce.com/products/shipping/', |
| 270 | 'is_visible' => array( |
| 271 | self::get_rules_for_countries( array( 'US' ) ), |
| 272 | (object) array( |
| 273 | 'type' => 'not', |
| 274 | 'operand' => array( |
| 275 | (object) array( |
| 276 | 'type' => 'plugins_activated', |
| 277 | 'plugins' => array( 'woocommerce-shipping' ), |
| 278 | ), |
| 279 | ), |
| 280 | ), |
| 281 | ), |
| 282 | 'available_layouts' => array( 'row', 'column' ), |
| 283 | 'countries_where_primary' => array( 'US' ), |
| 284 | ), |
| 285 | ); |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * Get rules that match the store base location to one of the provided countries. |
| 290 | * |
| 291 | * @param array $countries Array of countries to match. |
| 292 | * @return object Rules to match. |
| 293 | */ |
| 294 | public static function get_rules_for_countries( $countries ) { |
| 295 | return (object) array( |
| 296 | 'type' => 'base_location_country', |
| 297 | 'operation' => 'in', |
| 298 | 'value' => $countries, |
| 299 | ); |
| 300 | } |
| 301 | } |
| 302 |