Jump to content

Frais de port offert mais pas pour tous


Recommended Posts

Bonjour,

 

Je bloque sur un problème, je vous explique en faites, je vends des accessoires pour animaux, entre autres des graines et de grandes cages pour oiseaux pour oiseaux, ces fameux objets lourds et volumineux, je ne peux pas offrir les frais de port pour ces produits. 

 

Donc en faites j'ai bien défini le frais de port offert à partir de 100€ mais je voudrais faire quelques chose pour que si c'est des grandes cages ou des graines (+de 10kg) la gratuité ne soit pas pris en compte.
 

Pour info sur chaque produit le poids et indiqué. 

Merci de votre aide !

Link to comment
Share on other sites

Bonjour,

 

Vous pourriez peut-être paramétrer les frais de port au poids, avec une tranche plus de 10 kilos, port payant. Bien sûr si des clients ont l'habitude de vous achetez pour 10 kilos de graines ça ne résout pas votre problème.

Link to comment
Share on other sites

// Free fees
		$free_fees_price = 0;
		if ($this->getTotalWeight() < 10) {

		if (isset($configuration['PS_SHIPPING_FREE_PRICE']))
			$free_fees_price = Tools::convertPrice((float)$configuration['PS_SHIPPING_FREE_PRICE'], Currency::getCurrencyInstance((int)$this->id_currency));
		$orderTotalwithDiscounts = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, null, null, false);
		if ($orderTotalwithDiscounts >= (float)($free_fees_price) && (float)($free_fees_price) > 0)
		{
			Cache::store($cache_id, $shipping_cost);
			return $shipping_cost;
		}

		if (isset($configuration['PS_SHIPPING_FREE_WEIGHT'])
			&& $this->getTotalWeight() >= (float)$configuration['PS_SHIPPING_FREE_WEIGHT']
			&& (float)$configuration['PS_SHIPPING_FREE_WEIGHT'] > 0)
		{
			Cache::store($cache_id, $shipping_cost);
			return $shipping_cost;
		}

		// Get shipping cost using correct method
		if ($carrier->range_behavior)
		{
			// Get id zone
			if (isset($this->id_address_delivery)
				&& $this->id_address_delivery
				&& Customer::customerHasAddress($this->id_customer, $this->id_address_delivery))
				$id_zone = Address::getZoneById((int)$this->id_address_delivery);
			else
				$id_zone = (int)$default_country->id_zone;

			$check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight((int)$carrier->id, $this->getTotalWeight(), (int)$id_zone);

			// Code Review V&V TO FINISH
			$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice(
				$carrier->id,
				$this->getOrderTotal(
					true,
					Cart::BOTH_WITHOUT_SHIPPING,
					$product_list
				),
				$id_zone,
				(int)$this->id_currency
			);

			if ((
					$carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT
					&& !$check_delivery_price_by_weight
				) || (
					$carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE
					&& !$check_delivery_price_by_price
			))
				$shipping_cost += 0;
			else
			{
				if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT)
					$shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone);
				else // by price
					$shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int)$this->id_currency);
			}
		}
		else
		{
			if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT)
				$shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone);
			else
				$shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int)$this->id_currency);

		}
		// Adding handling charges
		if (isset($configuration['PS_SHIPPING_HANDLING']) && $carrier->shipping_handling)
			$shipping_cost += (float)$configuration['PS_SHIPPING_HANDLING'];

		// Additional Shipping Cost per product
		foreach ($products as $product)
			if (!$product['is_virtual'])
				$shipping_cost += $product['additional_shipping_cost'] * $product['cart_quantity'];

		$shipping_cost = Tools::convertPrice($shipping_cost, Currency::getCurrencyInstance((int)$this->id_currency));

		//get external shipping cost from module
		if ($carrier->shipping_external)
		{
			$module_name = $carrier->external_module_name;
			$module = Module::getInstanceByName($module_name);

			if (Validate::isLoadedObject($module))
			{
				if (array_key_exists('id_carrier', $module))
					$module->id_carrier = $carrier->id;
				if ($carrier->need_range)
					if (method_exists($module, 'getPackageShippingCost'))
						$shipping_cost = $module->getPackageShippingCost($this, $shipping_cost, $products);
					else
						$shipping_cost = $module->getOrderShippingCost($this, $shipping_cost);
				else
					$shipping_cost = $module->getOrderShippingCostExternal($this);

				// Check if carrier is available
				if ($shipping_cost === false)
				{
					Cache::store($cache_id, false);
					return false;
				}
			}
			else
			{
				Cache::store($cache_id, false);
				return false;
			}
		}

		// Apply tax
		if ($use_tax && isset($carrier_tax))
			$shipping_cost *= 1 + ($carrier_tax / 100);

		$shipping_cost = (float)Tools::ps_round((float)$shipping_cost, 2);
		Cache::store($cache_id, $shipping_cost);

		return $shipping_cost;
	}
	}

Dans mon fichier cart.php section // free fees j'ai fais ça. Qu'est ce qui cloche ?

Link to comment
Share on other sites

Je suppose que tu as dû faire des déclinaisons pour définir le prix des différentes tranches de poids pour les graines et de même pour les tailles des cages sur la fiche produit

Tu devrais peut être récupérer les id des différentes déclinaisons et les mettre dans la condition avec" AND $id_product_attribute !=  (id des déclinaisons auxquelles tu ne veux pas de frais de port offerts)" à mettre à la suite de :

 

if ($orderTotalwithDiscounts >= (float)($free_fees_price) && (float)($free_fees_price) > 0 AND 

 

et de même pour

 

&& (float)$configuration['PS_SHIPPING_FREE_WEIGHT'] > 0 AND 

Link to comment
Share on other sites

J'ai résolu mon soucis en rajoutant à cette ligne :

 

if (isset($configuration['PS_SHIPPING_FREE_WEIGHT'])

            && $this->getTotalWeight() >= (float)$configuration['PS_SHIPPING_FREE_WEIGHT']
            && (float)$configuration['PS_SHIPPING_FREE_WEIGHT'] > 0)

 

ceci :

 

if (isset($configuration['PS_SHIPPING_FREE_WEIGHT'])

            && $this->getTotalWeight() >= (float)$configuration['PS_SHIPPING_FREE_WEIGHT']
            && (float)$configuration['PS_SHIPPING_FREE_WEIGHT'] > 0 && $this->getTotalWeight() < 10)

 

Merci quand même pour vos réponses

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...