private function makeCostString() { $baseCost = $this->fee ? wc_format_localized_price($this->fee) : null; $weightRate = null; if ($cost = $this->weightRate->getCost()) { $weightRate .= wc_format_localized_price($cost); $weightUnit = get_option('woocommerce_weight_unit'); $step = $this->weightRate->getStep(); $weightRate = sprintf(__('%s per %s %s', 'woowbs'), $weightRate, $step ? wc_format_localized_decimal($step) : null, $weightUnit); if ($skip = $this->weightRate->getSkip()) { $weightRate = sprintf(__('%s (from %s %s)', 'woowbs'), $weightRate, $skip, $weightUnit); } } $cost = null; if ($baseCost && $weightRate) { $cost = sprintf(__('%s + %s'), $baseCost, $weightRate); } else { if ($baseCost || $weightRate) { $cost = $baseCost . $weightRate; } else { $cost = __('Free', 'woowbs'); } } return $cost; }
public function validateShippingClasses($key) { $rates = new WbsBucketRates(); $rows = (array) @$_POST[$this->getPostKey($key)]; foreach ($rows as $i => $row) { $rates->add(new WbsBucketRate(@$row['class'], self::receiveDecimal(@$row['fee']), WbsProgressiveRate::fromArray(self::receiveWeightRate(@$row['weight_rate'])))); } return $rates; }