本文整理汇总了PHP中Cart::getTotalWeight方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::getTotalWeight方法的具体用法?PHP Cart::getTotalWeight怎么用?PHP Cart::getTotalWeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::getTotalWeight方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInfoFromOrder
public function getInfoFromOrder($orderID, &$delivery)
{
$mOrder = new Order((int) $orderID);
if (NULL !== $mOrder) {
$mDeliveryAddress = new Address($mOrder->id_address_delivery);
if (NULL !== $mDeliveryAddress) {
// receiver address information
$delivery["receiver_firstname"] = $mDeliveryAddress->firstname;
$delivery["receiver_name"] = $mDeliveryAddress->lastname;
if ($mDeliveryAddress->company) {
$delivery["receiver_company"] = $mDeliveryAddress->company;
}
$delivery["receiver_address"] = $mDeliveryAddress->address1;
if ($mDeliveryAddress->address2) {
$delivery["receiver_address2"] = $mDeliveryAddress->address2;
}
$delivery["receiver_zipcode"] = $mDeliveryAddress->postcode;
$delivery["receiver_city"] = $mDeliveryAddress->city;
if ($mDeliveryAddress->phone_mobile) {
$delivery["receiver_cellphone"] = $mDeliveryAddress->phone_mobile;
}
if ($mDeliveryAddress->phone) {
$delivery["receiver_phone"] = $mDeliveryAddress->phone;
}
if ($mDeliveryAddress->other) {
$delivery["receiver_comments"] = $mDeliveryAddress->other;
}
}
$delivery["packet_reference"] = $mOrder->id;
$id_cart = (int) $mOrder->id_cart;
/* set weight */
$cart = new Cart($id_cart);
$delivery['weight'] = Configuration::get('PS_WEIGHT_UNIT') == 'g' ? (double) ($cart->getTotalWeight() / 1000) : (double) $cart->getTotalWeight();
/* set dejalaProductID and sender_availability = shipping date */
$djlCart = new DejalaCart($id_cart);
if (!is_null($djlCart) && !is_null($djlCart->id)) {
$mDejalaProductID = (int) $djlCart->id_dejala_product;
$delivery["product_id"] = (int) $mDejalaProductID;
$mShippingDate = $djlCart->shipping_date;
if (is_null($mShippingDate) || empty($mShippingDate)) {
$mShippingDate = 0;
}
$delivery["shipping_start_utc"] = $mShippingDate;
}
}
return $delivery;
}
示例2: systemPriceCalculate
/**
* Return price calculated by PrestaShop system
*
* @param $id_carrier string | int - carrier id
* @param $id_cart string | int - cart id
* @param $id_zone string | int - Zone Id 1 -> Global?
* @return string - Price
*/
public static function systemPriceCalculate($id_carrier, $id_cart, $id_zone)
{
$cart = new Cart($id_cart);
$total_weight = $cart->getTotalWeight();
$carrier = new Carrier($id_carrier);
$price = $carrier->getDeliveryPriceByWeight($total_weight, $id_zone);
return $price;
}
开发者ID:uab-balticode,项目名称:dpd-shipping-module-prestashop-2,代码行数:16,代码来源:dynamicparceldistribution.php
示例3: getOrderShippingCostExternal
/**
* @param \Cart $cart
*
* @return bool|float|int
* @throws \Exception
*
* @author Panagiotis Vagenas <pan.vagenas@gmail.com>
* @since ${VERSION}
*/
public function getOrderShippingCostExternal($cart)
{
$addressObj = new \Address($cart->id_address_delivery);
$country = mb_strtolower($addressObj->country);
$countryChecks = array('greece', 'ελλάδα', 'ελλαδα', 'ελλας', 'ελλάς', 'el', 'el_gr', 'ellada', 'ellas', 'hellas', 'gr');
if (!in_array($country, $countryChecks)) {
return false;
}
if ($cart->getOrderTotal(true, \Cart::ONLY_PRODUCTS) > $this->Options->getValue('freeShippingAbove')) {
return 0;
}
return $this->calculatePrice($cart->getTotalWeight());
}
示例4: getRatingServiceSelectionRequestXML
/**
* Generates the XML needed for the making a request to the Rating API
*
* @param $ups_config
* @param Cart $cart
* @param $RequestOption
* @param null $service
* @return string
*/
public function getRatingServiceSelectionRequestXML($ups_config, Cart $cart, $RequestOption /* Rate or Shop */, $service = NULL)
{
$shipping_address = $cart->getShippingAddress();
$request = "<?xml version=\"1.0\" ?>
<RatingServiceSelectionRequest>
<Request>
<TransactionReference>
<CustomerContext>Rating and Service</CustomerContext>
<XpciVersion>1.0</XpciVersion>
</TransactionReference>
<RequestAction>Rate</RequestAction>
<RequestOption>$RequestOption</RequestOption>
</Request>
<PickupType>
<Code>$ups_config->pickup_type</Code>
</PickupType>
<Shipment>
<Shipper>
<ShipperNumber>$ups_config->shipper_number</ShipperNumber>
<Address>
<PostalCode>$ups_config->postal_code</PostalCode>
<CountryCode>$ups_config->country_code</CountryCode>
</Address>
</Shipper>
<ShipFrom>
<Address>
<PostalCode>$ups_config->postal_code</PostalCode>
<CountryCode>$ups_config->country_code</CountryCode>
</Address>
</ShipFrom>
<ShipTo>
<!--<CompanyName>$shipping_address->company</CompanyName>
<AttentionName>$shipping_address->firstname $shipping_address->lastname</AttentionName>
<PhoneNumber>$shipping_address->telephone</PhoneNumber>-->
<Address>
<!-- <AddressLine1>$shipping_address->address</AddressLine1>
<City>$shipping_address->city</City> -->
<PostalCode>$shipping_address->postal_code</PostalCode>
<CountryCode>$shipping_address->country</CountryCode>
</Address>
</ShipTo>";
$request .= ( $service ? "<Service><Code>$service</Code></Service>" : '');
$request .= "<Package>
<PackagingType>
<Code>$ups_config->package_type</Code>
</PackagingType>
<!-- Dimensions are required if Packaging Type if not Letter, Express Tube,
or Express Box; Required for GB to GB and Poland to Poland shipments -->
<!-- <Dimensions>
<UnitOfMeasurement>
<Code>CM</Code>
</UnitOfMeasurement>
<Length>$length</Length>
<Width>$width</Width>
<Height>$height</Height>
</Dimensions>-->
<!-- Weight allowed for letters/envelopes.-->
<PackageWeight>
<UnitOfMeasurement>";
$request .= "<Code>" . ($cart->getUnitOfMeasure() == ShopInfo::UNIT_OF_MEASURE_KGS ? "KGS" : "LBS") . "</Code>";
$cart_weight = $cart->getTotalWeight();
$request .= "</UnitOfMeasurement>
<Weight>$cart_weight</Weight>
</PackageWeight>
</Package>
<ShipmentServiceOptions />
</Shipment>
</RatingServiceSelectionRequest>";
return $request;
}
示例5: calculate_freight
require_once "../includes/init.inc.php";
function calculate_freight($service, $cep_origin, $cep_destination, $weight, $own_hand, $declared_value, $notice_receipt)
{
$own_hand = strtolower($own_hand) == 's' ? 's' : 'n';
$notice_receipt = strtolower($notice_receipt) == 's' ? 's' : 'n';
$url = 'http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx?nCdEmpresa=&sDsSenha=&sCepOrigem=' . $cep_origin . '&sCepDestino=' . $cep_destination . '&nVlPeso=' . $weight . '&nCdFormato=1&nVlComprimento=20&nVlAltura=5&nVlLargura=15&sCdMaoPropria=' . $own_hand . '&nVlValorDeclarado=' . $declared_value . '&sCdAvisoRecebimento=' . $notice_receipt . '&nCdServico=' . $service . '&nVlDiametro=0&StrRetorno=xml';
$freight_calculate = simplexml_load_string(file_get_contents($url));
$freight = $freight_calculate->cServico;
if ($freight->Erro == '0') {
$response[0] = (double) str_replace(',', '.', $freight->Valor);
$response[1] = $freight->PrazoEntrega . ' dia' . ($freight->PrazoEntrega != 1 ? "s" : "");
} elseif ($freight->Erro == '7') {
$response[0] = 0;
$response[1] = 'Serviço temporariamente indisponível, tente novamente mais tarde.';
} else {
$response[0] = 0;
$response[1] = 'Erro no cálculo do frete: ' . $freight->MsgErro;
}
return $response;
}
if (isset($_GET['cep_destination'])) {
$cep_destination = $_GET['cep_destination'];
$_SESSION['cep_destination'] = $cep_destination;
$cep_destination = str_replace('-', '', $cep_destination);
$_SESSION['freight'] = calculate_freight('40010', '35400000', $cep_destination, Cart::getTotalWeight(), 'n', '0', 's');
} else {
unset($_SESSION['freight']);
unset($_SESSION['cep_destination']);
}
header("location: ../carrinho");
示例6: calculateShipping
/**
* Calculates shipping rates
*
* @param Cart $cart Shipping cart for which to calculate shipping; includes shipping address
* @param String $service Represents the specific service for which to calcualte shipping (e.g. Standard or Priority)
* @return null
*/
public function calculateShipping(Cart $cart, $service = NULL)
{
/** @var $unit The thing we will compare to the table rates: price, weight or item count */
$unit = NULL;
switch($this->type){
case TableRateShipping::TYPE_PRICE_DESTINATION:
$unit = $cart->getItemTotal(); // TODO Check if maybe getTotalAfterDiscount should be used instead
break;
case TableRateShipping::TYPE_WEIGHT_DESTINATION:
$unit = $cart->getTotalWeight();
break;
case TableRateShipping::TYPE_ITEMS_COUNT_DESTINATION:
$unit = count($cart->getProducts());
break;
}
$shipping_address = $cart->getShippingAddress();
$shipping_country = $shipping_address->country;
$table_rates = $this->getTableRatesForCountry($shipping_country);
$shipping_price = NULL;
foreach($table_rates as $table_rate)
{
if($table_rate->unit <= $unit)
{
$shipping_price = $table_rate->price;
}
else
{
break;
}
}
// If no shipping price was calculated, just take the last
if(is_null($shipping_price))
{
ShopLogger::log("Couldn't match any rules from the table;");
$shipping_price = $table_rate->price;
}
return $shipping_price;
}