count( $this->optionsProvider->getStatusSyncingPacketStatuses( $this->packetSynchronizer->getDefaultPacketStatuses() ) ) > 0 && count( $this->optionsProvider->getExistingStatusSyncingOrderStatuses() ) > 0 ), new DashboardItem( $this->wpAdapter->__( 'Set up automatic shipment submission', 'packeta' ), $this->wpAdapter->adminUrl( 'admin.php?page=' . Options\Page::SLUG . '&tab=' . Options\Page::TAB_AUTO_SUBMISSION . '&wizard-enabled=true&wizard-auto-submission-tour-enabled=true' ), $this->wpAdapter->__( 'Use this if you want to automatically submit shipments based on the order status.', 'packeta' ), 8, $this->optionsProvider->isPacketAutoSubmissionEnabled() && count( $this->optionsProvider->getPacketAutoSubmissionMappedUniqueEvents() ) > 0 ), ]; } private function getNewestProductUrl(): ?string { $args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'orderby' => 'date', 'order' => 'DESC', ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { $query->the_post(); $editUrl = $this->wpAdapter->getEditPostLink( $this->wpAdapter->getTheId(), '' ); $this->wpAdapter->resetPostdata(); return $editUrl; } return null; } private function getProductSettingsDescription(): string { $suffix = ''; if ( $this->getNewestProductUrl() === null ) { $suffix = ' ' . $this->wpAdapter->__( 'First create at least one product.', 'packeta' ); } return $this->wpAdapter->__( 'For each product, you can set it to be intended for adults only, or disable specific Packeta carriers for this product.', 'packeta' ) . $suffix; } private function getCarrierUpdateUrl(): ?string { if ( $this->optionsProvider->get_api_password() === null ) { return null; } if ( $this->carrierUpdater->getLastUpdate() !== null ) { return $this->wpAdapter->adminUrl( 'admin.php?page=' . Carrier\OptionsPage::SLUG . '&update_carriers=1' ); } return $this->wpAdapter->adminUrl( 'admin.php?page=' . DashboardPage::SLUG . '&update_carriers=1' ); } private function hasProductsWithPacketaSettings(): bool { $args = [ 'post_type' => 'product', 'posts_per_page' => 1, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query 'meta_query' => [ 'relation' => 'OR', [ 'key' => Product\Entity::META_AGE_VERIFICATION_18_PLUS, 'value' => '1', 'compare' => '=', ], [ 'relation' => 'AND', [ 'key' => Product\Entity::META_DISALLOWED_SHIPPING_RATES, 'compare' => 'EXISTS', ], [ 'key' => Product\Entity::META_DISALLOWED_SHIPPING_RATES, 'value' => 'a:0:{}', 'compare' => '!=', ], ], ], ]; $query = new WP_Query( $args ); if ( $query->have_posts() ) { return true; } return false; } }