Skip to content

Commit

Permalink
Merge branch 'refs/heads/gh-7'
Browse files Browse the repository at this point in the history
  • Loading branch information
DEMAxx committed Jun 18, 2024
2 parents 05d7ddb + 88f0389 commit c9e2c4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
14 changes: 0 additions & 14 deletions src/UI/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,9 @@ public static function registerAdminScripts(): void
]);
}

public static function registerOrderScripts(): void
{
global $plugin_page, $pagenow;

// Not on an Orders page.
if ('admin.php' !== $pagenow || 0 !== strpos($plugin_page, 'wc-orders')) {
return;
}

Helper::enqueueScript('cdek-admin-create-order', 'cdek-create-order', true);
}

public function __invoke(): void
{
add_action('load-woocommerce_page_wc-settings', [__CLASS__, 'registerAdminScripts']);

add_action('admin_enqueue_scripts', [__CLASS__, 'registerOrderScripts']);
}
}

Expand Down
19 changes: 13 additions & 6 deletions src/UI/MetaBoxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public static function registerMetaBoxes(string $post_type, $post): void
return;
}

add_action('admin_enqueue_scripts', [__CLASS__, 'registerOrderScripts']);

$cdekMethod = CheckoutHelper::getOrderShippingMethod($order);
$selectedTariff = (int) ($cdekMethod->get_meta(MetaKeys::TARIFF_CODE) ?:
$cdekMethod->get_meta('tariff_code'));
Expand Down Expand Up @@ -87,7 +89,7 @@ public static function noAddressMetaBox(): void
str_replace('<a>', '<a href="'.esc_url($settings_page_url).'">',
sprintf(esc_html__(/* translators: %s: Name of the plugin */ 'Select the correct sending address in <a>the settings</a> plugin named %s',
'cdekdelivery'),
esc_html($pluginName))).
esc_html($pluginName))).
'</p>
</div>';
}
Expand All @@ -104,7 +106,7 @@ public static function noOfficeMetaBox(): void
str_replace('<a>', '<a href="'.esc_url($settings_page_url).'">',
sprintf(esc_html__(/* translators: %s: Name of the plugin */ 'Select the correct sending address in <a>the settings</a> plugin named %s',
'cdekdelivery'),
esc_html($pluginName))).
esc_html($pluginName))).
'</p>
</div>';
}
Expand All @@ -121,7 +123,7 @@ public static function noAuthMetaBox(): void
str_replace('<a>', '<a href="'.esc_url($settings_page_url).'">',
sprintf(esc_html__(/* translators: %s: Name of the plugin */ 'Enter the correct client ID and secret key in <a>the settings</a> plugin named %s',
'cdekdelivery'),
esc_html($pluginName))).
esc_html($pluginName))).
'</p>
</div>';
}
Expand All @@ -144,8 +146,8 @@ public static function createOrderMetaBox($post): void
$shipping = CheckoutHelper::getOrderShippingMethod($order);

$hasPackages
= Helper::getActualShippingMethod($shipping->get_data()['instance_id'])
->get_option('has_packages_mode') === 'yes';
= Helper::getActualShippingMethod($shipping->get_data()['instance_id'])
->get_option('has_packages_mode') === 'yes';
$orderNumber = $orderData['order_number'] ?? null;
$orderUuid = $orderData['order_uuid'] ?? null;

Expand Down Expand Up @@ -180,11 +182,16 @@ public static function notAvailableEditOrderData(): void
echo '<div class="notice notice-warning"><p>
<strong>CDEKDelivery:</strong> '.
esc_html__('Editing the order is not available due to a change in the order status in the CDEK system',
'cdekdelivery').
'cdekdelivery').
'
</p></div>';
}

public static function registerOrderScripts(): void
{
Helper::enqueueScript('cdek-admin-create-order', 'cdek-create-order', true);
}

public function __invoke(): void
{
add_action('add_meta_boxes', [__CLASS__, 'registerMetaBoxes'], 100, 2);
Expand Down

0 comments on commit c9e2c4c

Please sign in to comment.