id = ACS_POINTS_PLUGIN_ID;
$this->title = __(AcsPointsPlugin::$labels['checkout_option_title'], ACS_POINTS_PLUGIN_ID);
$this->method_title = __(AcsPointsPlugin::$labels['checkout_option_title'], ACS_POINTS_PLUGIN_ID);
$this->method_description = '';
$this->availability = 'including';
$settings = AcsPointsPlugin::getSettings();
$this->countries = ['GR', 'CY'];
if (isset($settings['countries_availability']) && $settings['countries_availability'] == 'gr') {
$this->countries = ['GR'];
} elseif (isset($settings['countries_availability']) && $settings['countries_availability'] == 'cy') {
$this->countries = ['CY'];
}
$this->enabled = $settings['enabled'];
add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'process_admin_options'));
}
function admin_options()
{
?>
title); ?>
calculate($sender_country, $sender_zipcode, $sender_billing_code, $recipient_country, $recipient_zipcode);
$baseCost = (!isset($settings['pricing'][$costGroup]['baseCost'])
|| $settings['pricing'][$costGroup]['baseCost'] == '')
? 0
: $settings['pricing'][$costGroup]['baseCost'];
$baseCostKgLimit = (!isset($settings['pricing'][$costGroup]['baseCostKgLimit'])
|| $settings['pricing'][$costGroup]['baseCostKgLimit'] == '')
? 0
: $settings['pricing'][$costGroup]['baseCostKgLimit'];
$costPerKg = (!isset($settings['pricing'][$costGroup]['costPerKg'])
|| $settings['pricing'][$costGroup]['costPerKg'] == '')
? 0
: $settings['pricing'][$costGroup]['costPerKg'];
$freeShippingLimit = $settings['freeShippingUpperLimit'];
$optionCost = 0;
$orderTotalCost = 0;
$weightTotal = 0;
foreach ($package['contents'] as $item_id => $values) {
$_product = $values['data'];
$qty = $values['quantity'] ?? 1;
$tempWeight = (float)$_product->get_weight();
$weightTotal += wc_get_weight($qty * $tempWeight, 'kg');
$orderTotalCost += $qty * $_product->get_price();
}
$weightTotal = ceil($weightTotal);
if ($freeShippingLimit != '' && $orderTotalCost < $freeShippingLimit) {
$optionCost = $baseCost;
if ($weightTotal > $baseCostKgLimit) {
$optionCost += $costPerKg * ($weightTotal - $baseCostKgLimit);
}
}
if ($weightTotal > (int)$settings['weightUpperLimit']) {
return;
}
$rate = array(
'id' => $this->id,
'label' => $this->title,
'cost' => $optionCost
);
$this->add_rate($rate);
}
}
});