| @@ -2,9 +2,8 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Packetery\Module\Views; |
| 4 | 4 | |
| 5 | 5 | use Packetery\Module\ContextResolver; |
| 6 | -use Packetery\Module\Framework\WcAdapter; | |
| 7 | 6 | use Packetery\Module\Framework\WpAdapter; |
| 8 | 7 | use Packetery\Module\Options\OptionNames; |
| 9 | 8 | use Packetery\Module\Options\Page; |
| 10 | 9 | use Packetery\Module\Order\DetailCommonLogic; |
| @@ -9,37 +8,41 @@ | ||
| 9 | 8 | use Packetery\Module\Options\Page; |
| 10 | 9 | use Packetery\Module\Order\DetailCommonLogic; |
| 11 | 10 | use Packetery\Module\Shipping\ShippingProvider; |
| 12 | 11 | use Packetery\Nette\Http\Request; |
| 13 | -use WC_Abstract_Order; | |
| 14 | 12 | |
| 15 | 13 | class WizardAssetManager { |
| 16 | - | |
| 17 | - /** @var WpAdapter */ | |
| 14 | + /** | |
| 15 | + * @var WpAdapter | |
| 16 | + */ | |
| 18 | 17 | private $wpAdapter; |
| 19 | 18 | |
| 20 | - /** @var AssetManager */ | |
| 19 | + /** | |
| 20 | + * @var AssetManager | |
| 21 | + */ | |
| 21 | 22 | private $assetManager; |
| 22 | 23 | |
| 23 | - /** @var Request */ | |
| 24 | + /** | |
| 25 | + * @var Request | |
| 26 | + */ | |
| 24 | 27 | private $request; |
| 25 | 28 | |
| 26 | - /** @var ContextResolver */ | |
| 29 | + /** | |
| 30 | + * @var ContextResolver | |
| 31 | + */ | |
| 27 | 32 | private $contextResolver; |
| 28 | 33 | |
| 29 | - /** @var DetailCommonLogic */ | |
| 34 | + /** | |
| 35 | + * @var DetailCommonLogic | |
| 36 | + */ | |
| 30 | 37 | private $detailCommonLogic; |
| 31 | 38 | |
| 32 | - /** @var WcAdapter */ | |
| 33 | - private $wcAdapter; | |
| 34 | - | |
| 35 | 39 | public function __construct( |
| 36 | 40 | AssetManager $assetManager, |
| 37 | 41 | Request $request, |
| 38 | 42 | WpAdapter $wpAdapter, |
| 39 | 43 | ContextResolver $contextResolver, |
| 40 | - DetailCommonLogic $detailCommonLogic, | |
| 41 | - WcAdapter $wcAdapter | |
| 44 | + DetailCommonLogic $detailCommonLogic | |
| 42 | 45 | ) { |
| 43 | 46 | $this->assetManager = $assetManager; |
| 44 | 47 | $this->request = $request; |
| 45 | 48 | $this->wpAdapter = $wpAdapter; |
| @@ -44,9 +47,8 @@ | ||
| 44 | 47 | $this->request = $request; |
| 45 | 48 | $this->wpAdapter = $wpAdapter; |
| 46 | 49 | $this->contextResolver = $contextResolver; |
| 47 | 50 | $this->detailCommonLogic = $detailCommonLogic; |
| 48 | - $this->wcAdapter = $wcAdapter; | |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | 53 | public function enqueueWizardAssets(): void { |
| 52 | 54 | $page = $this->request->getQuery( 'page' ); |
| @@ -152,9 +154,9 @@ | ||
| 152 | 154 | * @param array<string, array<string, string|null>|string|null> $basicTranslations |
| 153 | 155 | */ |
| 154 | 156 | private function createGeneralSettingsTour( array $basicTranslations ): void { |
| 155 | 157 | $translations = [ |
| 156 | - 'apiPassword' => [ | |
| 158 | + 'apiPassword' => [ | |
| 157 | 159 | 'title' => $this->wpAdapter->__( 'API password', 'packeta' ), |
| 158 | 160 | 'description' => sprintf( |
| 159 | 161 | $this->wpAdapter->__( 'API password can be found at %s', 'packeta' ), |
| 160 | 162 | '<a href="https://client.packeta.com/support" target="_blank">https://client.packeta.com/support<a/>' |
| @@ -159,9 +161,9 @@ | ||
| 159 | 161 | $this->wpAdapter->__( 'API password can be found at %s', 'packeta' ), |
| 160 | 162 | '<a href="https://client.packeta.com/support" target="_blank">https://client.packeta.com/support<a/>' |
| 161 | 163 | ), |
| 162 | 164 | ], |
| 163 | - 'apiSender' => [ | |
| 165 | + 'apiSender' => [ | |
| 164 | 166 | 'title' => $this->wpAdapter->__( 'Sender', 'packeta' ), |
| 165 | 167 | 'description' => sprintf( |
| 166 | 168 | /* translators: 1: emphasis start 2: emphasis end 3: client section link start 4: client section link end */ |
| 167 | 169 | esc_html__( 'Fill in the %1$ssender label%2$s here - you will find it in %3$sclient section%4$s - user information - field \'Indication\'.', 'packeta' ), |
| @@ -170,80 +172,72 @@ | ||
| 170 | 172 | '<a href="https://client.packeta.com/senders" target="_blank">', |
| 171 | 173 | '</a>' |
| 172 | 174 | ), |
| 173 | 175 | ], |
| 174 | - 'packetaLabelFormat' => [ | |
| 176 | + 'packetaLabelFormat' => [ | |
| 175 | 177 | 'title' => $this->wpAdapter->__( 'Packeta Label Format', 'packeta' ), |
| 176 | 178 | 'description' => $this->wpAdapter->__( 'Select the label print format for Packeta according to your printer.', 'packeta' ), |
| 177 | 179 | ], |
| 178 | - 'carrierLabelFormat' => [ | |
| 180 | + 'carrierLabelFormat' => [ | |
| 179 | 181 | 'title' => $this->wpAdapter->__( 'Carrier Label Format', 'packeta' ), |
| 180 | 182 | 'description' => $this->wpAdapter->__( 'Select the label print format for the carrier according to your printer.', 'packeta' ), |
| 181 | 183 | ], |
| 182 | - 'cod' => [ | |
| 184 | + 'cod' => [ | |
| 183 | 185 | 'title' => $this->wpAdapter->__( 'Payment methods that represent cash on delivery', 'packeta' ), |
| 184 | 186 | 'description' => $this->wpAdapter->__( 'Select the payment method that will be set as cash on delivery. This information will be passed to the carrier to calculate surcharges.', 'packeta' ), |
| 185 | 187 | ], |
| 186 | - 'packagingWeight' => [ | |
| 188 | + 'packagingWeight' => [ | |
| 187 | 189 | 'title' => $this->wpAdapter->__( 'Weight of packaging material', 'packeta' ), |
| 188 | 190 | 'description' => $this->wpAdapter->__( 'This parameter is used to determine the weight of the packaging material. This value is automatically added to the total weight of each order that contains products with non-zero weight. It is also taken into account when evaluating weight rules in the cart.', 'packeta' ), |
| 189 | 191 | ], |
| 190 | - 'defaultWeightEnabled' => [ | |
| 192 | + 'defaultWeightEnabled' => [ | |
| 191 | 193 | 'title' => $this->wpAdapter->__( 'Enable default weight', 'packeta' ), |
| 192 | 194 | 'description' => $this->wpAdapter->__( 'If no weight is set for the products in order, this value will be used.', 'packeta' ), |
| 193 | 195 | ], |
| 194 | - 'dimensionsUnit' => [ | |
| 196 | + 'dimensionsUnit' => [ | |
| 195 | 197 | 'title' => $this->wpAdapter->__( 'Units used for dimensions', 'packeta' ), |
| 196 | 198 | 'description' => $this->wpAdapter->__( 'Units used for package dimensions, such as centimeters (cm) or millimeters (mm).', 'packeta' ), |
| 197 | 199 | ], |
| 198 | - 'dimensionsEnabled' => [ | |
| 200 | + 'dimensionsEnabled' => [ | |
| 199 | 201 | 'title' => $this->wpAdapter->__( 'Enable default dimensions', 'packeta' ), |
| 200 | 202 | 'description' => $this->wpAdapter->__( 'When enabled, these values will be automatically used for any order that contains products with zero dimensions.', 'packeta' ), |
| 201 | 203 | ], |
| 202 | - 'pickupPointAddress' => [ | |
| 204 | + 'pickupPointAddress' => [ | |
| 203 | 205 | 'title' => $this->wpAdapter->__( 'Replace shipping address with pickup point address', 'packeta' ), |
| 204 | 206 | 'description' => $this->wpAdapter->__( 'If this option is enabled, the customers shipping address will automatically be replaced with the selected pickup point address.', 'packeta' ), |
| 205 | 207 | ], |
| 206 | - 'checkoutDetection' => [ | |
| 208 | + 'checkoutDetection' => [ | |
| 207 | 209 | 'title' => $this->wpAdapter->__( 'Force checkout type', 'packeta' ), |
| 208 | 210 | 'description' => $this->wpAdapter->__( 'If you have trouble displaying the widget button in the checkout, you can set what type of checkout you are using.', 'packeta' ), |
| 209 | 211 | ], |
| 210 | - 'widgetButtonLocation' => [ | |
| 212 | + 'widgetButtonLocation' => [ | |
| 211 | 213 | 'title' => $this->wpAdapter->__( 'Widget button location in checkout', 'packeta' ), |
| 212 | 214 | 'description' => $this->wpAdapter->__( 'Determines where the pickup point selection button will appear at checkout.', 'packeta' ), |
| 213 | 215 | ], |
| 214 | - 'hideLogo' => [ | |
| 216 | + 'hideLogo' => [ | |
| 215 | 217 | 'title' => $this->wpAdapter->__( 'Hide Packeta checkout logo', 'packeta' ), |
| 216 | 218 | 'description' => $this->wpAdapter->__( 'Hides the Packeta logo at checkout.', 'packeta' ), |
| 217 | 219 | ], |
| 218 | - 'emailHook' => [ | |
| 220 | + 'emailHook' => [ | |
| 219 | 221 | 'title' => $this->wpAdapter->__( 'Hook used to view information in email', 'packeta' ), |
| 220 | 222 | 'description' => $this->wpAdapter->__( 'This option determines where the pickup point information will be displayed in the e-mail. Choose the appropriate option based on the structure of e-mails in your e-shop.', 'packeta' ), |
| 221 | 223 | ], |
| 222 | - 'forcePacketCancel' => [ | |
| 224 | + 'forcePacketCancel' => [ | |
| 223 | 225 | 'title' => $this->wpAdapter->__( 'Force order cancellation', 'packeta' ), |
| 224 | 226 | 'description' => $this->wpAdapter->__( 'Cancel the packet for an order even if the cancellation in the Packeta system will not be successful.', 'packeta' ), |
| 225 | 227 | ], |
| 226 | - 'widgetAutoOpen' => [ | |
| 228 | + 'widgetAutoOpen' => [ | |
| 227 | 229 | 'title' => $this->wpAdapter->__( 'Automatically open widget when shipping was selected', 'packeta' ), |
| 228 | 230 | 'description' => $this->wpAdapter->__( 'If this option is active, the widget for selecting pickup points will open automatically after selecting the shipping method at the checkout.', 'packeta' ), |
| 229 | 231 | ], |
| 230 | - 'freeShippingShown' => [ | |
| 232 | + 'freeShippingShown' => [ | |
| 231 | 233 | 'title' => $this->wpAdapter->__( 'Display the FREE shipping text in checkout', 'packeta' ), |
| 232 | 234 | 'description' => $this->wpAdapter->__( 'If enabled, "FREE" will be displayed after the name of the shipping method, if free shipping is applied.', 'packeta' ), |
| 233 | 235 | ], |
| 234 | - 'pricesIncludeTax' => [ | |
| 236 | + 'pricesIncludeTax' => [ | |
| 235 | 237 | 'title' => $this->wpAdapter->__( 'Prices include tax', 'packeta' ), |
| 236 | 238 | 'description' => $this->wpAdapter->__( 'If enabled, VAT will not be added to shipping prices and surcharges.', 'packeta' ), |
| 237 | 239 | ], |
| 238 | - 'pickupPointValidationEnabled' => [ | |
| 239 | - 'title' => $this->wpAdapter->__( 'Validate the pickup point using the API before accepting the order', 'packeta' ), | |
| 240 | - 'description' => $this->wpAdapter->__( 'If enabled, selected pickup point will be validated using the API to prevent bypassing widget restrictions.', 'packeta' ), | |
| 241 | - ], | |
| 242 | - 'showConsignPasswordForZBox' => [ | |
| 243 | - 'title' => $this->wpAdapter->__( 'Show consignment code', 'packeta' ), | |
| 244 | - 'description' => $this->wpAdapter->__( 'If enabled, the consignment code will be fetched after packet creation and displayed in the order metabox and on the AWB printout.', 'packeta' ), | |
| 245 | - ], | |
| 246 | 240 | ]; |
| 247 | 241 | |
| 248 | 242 | $this->enqueueTourScript( 'admin-wizard-general-settings.js', array_merge( $translations, $basicTranslations ) ); |
| 249 | 243 | } |
| @@ -349,97 +343,93 @@ | ||
| 349 | 343 | } |
| 350 | 344 | |
| 351 | 345 | private function createOrderDetailEditPacketTour( array $basicTranslations ): void { |
| 352 | 346 | $translations = [ |
| 353 | - 'weight' => [ | |
| 347 | + 'weight' => [ | |
| 354 | 348 | 'title' => $this->wpAdapter->__( 'Weight', 'packeta' ), |
| 355 | 349 | 'description' => $this->wpAdapter->__( 'Here you see the shipment weight, calculated from the products in the order. If products don’t have a weight, the default value set in the plugin settings will be used. You can also adjust it manually.', 'packeta' ), |
| 356 | 350 | ], |
| 357 | - 'length' => [ | |
| 351 | + 'length' => [ | |
| 358 | 352 | 'title' => $this->wpAdapter->__( 'Length', 'packeta' ), |
| 359 | 353 | 'description' => $this->wpAdapter->__( 'Enter the shipment length in mm or cm, depending on plugin settings. The length of the largest product in the order is used. If the product has no dimensions, the default from plugin settings is used. You can also adjust it manually.', 'packeta' ), |
| 360 | 354 | ], |
| 361 | - 'width' => [ | |
| 355 | + 'width' => [ | |
| 362 | 356 | 'title' => $this->wpAdapter->__( 'Width', 'packeta' ), |
| 363 | 357 | 'description' => $this->wpAdapter->__( 'Enter the shipment width in mm or cm, depending on plugin settings. The width of the largest product in the order is used. If the product has no dimensions, the default from plugin settings is used. You can also adjust it manually.', 'packeta' ), |
| 364 | 358 | ], |
| 365 | - 'height' => [ | |
| 359 | + 'height' => [ | |
| 366 | 360 | 'title' => $this->wpAdapter->__( 'Height', 'packeta' ), |
| 367 | 361 | 'description' => $this->wpAdapter->__( 'Enter the shipment height in mm or cm, depending on plugin settings. The height of the largest product in the order is used. If the product has no dimensions, the default from plugin settings is used. You can also adjust it manually.', 'packeta' ), |
| 368 | 362 | ], |
| 369 | - 'adultContent' => [ | |
| 363 | + 'adultContent' => [ | |
| 370 | 364 | 'title' => $this->wpAdapter->__( 'Adult content', 'packeta' ), |
| 371 | 365 | 'description' => $this->wpAdapter->__( 'Automatically checked for orders with adult products.', 'packeta' ), |
| 372 | 366 | ], |
| 373 | - 'cod' => [ | |
| 367 | + 'cod' => [ | |
| 374 | 368 | 'title' => $this->wpAdapter->__( 'COD', 'packeta' ), |
| 375 | 369 | 'description' => $this->wpAdapter->__( 'You can edit the cash on delivery manually, otherwise the total order value is used.', 'packeta' ), |
| 376 | 370 | ], |
| 377 | - 'value' => [ | |
| 371 | + 'value' => [ | |
| 378 | 372 | 'title' => $this->wpAdapter->__( 'Value', 'packeta' ), |
| 379 | 373 | 'description' => $this->wpAdapter->__( 'You can edit the packet value manually, otherwise the total order price is used.', 'packeta' ), |
| 380 | 374 | ], |
| 381 | - 'deliverOn' => [ | |
| 375 | + 'deliverOn' => [ | |
| 382 | 376 | 'title' => $this->wpAdapter->__( 'Deliver on', 'packeta' ), |
| 383 | 377 | 'description' => $this->wpAdapter->__( 'Deferred delivery date – if set, the packet will be ready for pickup from this date onward.', 'packeta' ), |
| 384 | 378 | ], |
| 385 | - 'pickupPoint' => [ | |
| 379 | + 'pickupPoint' => [ | |
| 386 | 380 | 'title' => $this->wpAdapter->__( 'Pickup point', 'packeta' ), |
| 387 | 381 | 'description' => $this->wpAdapter->__( 'Here you can change the pickup point where the packet will be delivered.', 'packeta' ), |
| 388 | 382 | ], |
| 389 | - 'pickupAddress' => [ | |
| 383 | + 'pickupAddress' => [ | |
| 390 | 384 | 'title' => $this->wpAdapter->__( 'Pickup address', 'packeta' ), |
| 391 | 385 | 'description' => $this->wpAdapter->__( 'Here you can change the delivery address of the packet via the widget.', 'packeta' ), |
| 392 | 386 | ], |
| 393 | - 'trackingUrl' => [ | |
| 387 | + 'trackingUrl' => [ | |
| 394 | 388 | 'title' => $this->wpAdapter->__( 'Tracking url', 'packeta' ), |
| 395 | 389 | 'description' => $this->wpAdapter->__( 'Here you can find the URL to track the packet, you can click through to online tracking.', 'packeta' ), |
| 396 | 390 | ], |
| 397 | - 'zboxConsignPassword' => [ | |
| 398 | - 'title' => $this->wpAdapter->__( 'Consignment code', 'packeta' ), | |
| 399 | - 'description' => $this->wpAdapter->__( 'Consignment code for submitting the packet. Shown only when enabled in general settings and after the consignment code has been fetched from Packeta.', 'packeta' ), | |
| 400 | - ], | |
| 401 | - 'claimTrackingUrl' => [ | |
| 391 | + 'claimTrackingUrl' => [ | |
| 402 | 392 | 'title' => $this->wpAdapter->__( 'Claim tracking url', 'packeta' ), |
| 403 | 393 | 'description' => $this->wpAdapter->__( 'Here you can find the URL to track the claim packet (Claim Assistant), you can click through to online tracking.', 'packeta' ), |
| 404 | 394 | ], |
| 405 | - 'claimPassword' => [ | |
| 395 | + 'claimPassword' => [ | |
| 406 | 396 | 'title' => $this->wpAdapter->__( 'Claim password', 'packeta' ), |
| 407 | 397 | 'description' => $this->wpAdapter->__( 'Password required to submit the packet via Claim Assistant.', 'packeta' ), |
| 408 | 398 | ], |
| 409 | - 'buttonSubmitPacket' => [ | |
| 399 | + 'buttonSubmitPacket' => [ | |
| 410 | 400 | 'title' => $this->wpAdapter->__( 'Submit', 'packeta' ), |
| 411 | 401 | 'description' => $this->wpAdapter->__( 'Use this button to submit the packet. Clicking it will send the packet to the Packeta system', 'packeta' ), |
| 412 | 402 | ], |
| 413 | - 'buttonCancel' => [ | |
| 403 | + 'buttonCancel' => [ | |
| 414 | 404 | 'title' => $this->wpAdapter->__( 'Cancel', 'packeta' ), |
| 415 | 405 | 'description' => $this->wpAdapter->__( 'Button to cancel the packet. Clicking it will cancel the packet in the Packeta system, allowing you to submit it again.', 'packeta' ), |
| 416 | 406 | ], |
| 417 | - 'print' => [ | |
| 407 | + 'print' => [ | |
| 418 | 408 | 'title' => $this->wpAdapter->__( 'Print', 'packeta' ), |
| 419 | 409 | 'description' => $this->wpAdapter->__( 'Clicking this button opens a PDF of the label ready for printing.', 'packeta' ), |
| 420 | 410 | ], |
| 421 | - 'storedUnitl' => [ | |
| 411 | + 'storedUnitl' => [ | |
| 422 | 412 | 'title' => $this->wpAdapter->__( 'Stored until', 'packeta' ), |
| 423 | 413 | 'description' => $this->wpAdapter->__( 'Here you can see the date until which the packet can be picked up (shown if shipment tracking is enabled and the packet is ready for pickup).', 'packeta' ), |
| 424 | 414 | ], |
| 425 | - 'claimUrl' => [ | |
| 415 | + 'claimUrl' => [ | |
| 426 | 416 | 'title' => $this->wpAdapter->__( 'Claim url', 'packeta' ), |
| 427 | 417 | 'description' => $this->wpAdapter->__( 'Here you can find the URL to track the packet, you can click through to online tracking.', 'packeta' ), |
| 428 | 418 | ], |
| 429 | - 'claimLabel' => [ | |
| 419 | + 'claimLabel' => [ | |
| 430 | 420 | 'title' => $this->wpAdapter->__( 'Claim label', 'packeta' ), |
| 431 | 421 | 'description' => $this->wpAdapter->__( 'Here you can find the URL to track the claim packet (claim assistant), you can click through to online tracking.', 'packeta' ), |
| 432 | 422 | ], |
| 433 | - 'cancelClaim' => [ | |
| 423 | + 'cancelClaim' => [ | |
| 434 | 424 | 'title' => $this->wpAdapter->__( 'Cancel claim', 'packeta' ), |
| 435 | 425 | 'description' => $this->wpAdapter->__( 'Button to cancel a claim assistant packet. Clicking it will cancel the packet in the Packeta system, and you’ll be able to submit it again.', 'packeta' ), |
| 436 | 426 | ], |
| 437 | - 'packetStatus' => [ | |
| 427 | + 'packetStatus' => [ | |
| 438 | 428 | 'title' => $this->wpAdapter->__( 'Packet status', 'packeta' ), |
| 439 | 429 | 'description' => $this->wpAdapter->__( 'Here you can see the current stage of the packet (shown only if this option is enabled in the plugin settings).', 'packeta' ), |
| 440 | 430 | ], |
| 441 | - 'logsLink' => [ | |
| 431 | + 'logsLink' => [ | |
| 442 | 432 | 'title' => $this->wpAdapter->__( 'Logs', 'packeta' ), |
| 443 | 433 | 'description' => $this->wpAdapter->__( 'Button that, when clicked, shows the logs for this order. This lets you easily check what actions have been taken on the order in the system.', 'packeta' ), |
| 444 | 434 | ], |
| 445 | 435 | ]; |
| @@ -570,9 +560,9 @@ | ||
| 570 | 560 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only reading paged parameter for listing |
| 571 | 561 | $page = isset( $_GET['paged'] ) ? max( 1, (int) $_GET['paged'] ) : 1; |
| 572 | 562 | $limit = get_option( 'edit_shop_order_per_page', 20 ); |
| 573 | 563 | |
| 574 | - $orders = $this->wcAdapter->getOrdersWithoutPagination( | |
| 564 | + $orders = wc_get_orders( | |
| 575 | 565 | [ |
| 576 | 566 | 'limit' => $limit, |
| 577 | 567 | 'page' => $page, |
| 578 | 568 | 'status' => array_keys( wc_get_order_statuses() ), |
| @@ -579,13 +569,12 @@ | ||
| 579 | 569 | 'orderby' => 'date', |
| 580 | 570 | 'order' => 'DESC', |
| 581 | 571 | ] |
| 582 | 572 | ); |
| 583 | - if ( is_array( $orders ) ) { | |
| 584 | - foreach ( $orders as $order ) { | |
| 585 | - if ( $order instanceof WC_Abstract_Order && ShippingProvider::wcOrderHasOurMethod( $order ) ) { | |
| 586 | - return true; | |
| 587 | - } | |
| 573 | + | |
| 574 | + foreach ( $orders as $order ) { | |
| 575 | + if ( ShippingProvider::wcOrderHasOurMethod( $order ) ) { | |
| 576 | + return true; | |
| 588 | 577 | } |
| 589 | 578 | } |
| 590 | 579 | |
| 591 | 580 | return false; |