Jump to content

2nd carrier on order page, only one in BO


RamsesLeroi

Recommended Posts

Hi, i have a webshop with only 1 carrier.

 

When i try to order something it shows 2 carrieres even is there is only 1 carrier in the backoffice.

 

The second carrier has free shipping so this is a problem.

 

We already got orders we made a loss on because of the free shipping.

 

 

33x8ub9.png

 

When i click on the first carrier (the only one that's supposed to be showing) and click next, and then back again, the second carrier is gone. Also sometimes when I disable the cache it 'fixes' the problem temporally (but only on this computer).

 

Hope someone can help me?

 

 

Link to comment
Share on other sites

Ramses,

try this:

 

go to your host and start your database manager (cPanel->phpMyAdmin or so)

go to your database and

 

- select table ps_carrier_lang

post-455771-0-98056500-1397327568_thumb.png

- check the name of the carrier you DON'T want anymore.

- Check which id_carrier belongs to that one

 

 

- Then select ps_carrier table

post-455771-0-83742000-1397327807_thumb.png

- check which row has the id_carrier that belongs to the carrier you DON'T want

- of that row, click in the "active" field and change the 1 to 0 (zero)

 

see if the problem is solved in the front office.

 

Hope this helps,

pascal

Link to comment
Share on other sites

  • 5 weeks later...

I tried both you solutions, but none worked.

I deleted all the active carriers in the database, readded them in the backoffice but the free carrier is still there.

The weird thing is that it's a multishop and the problem is only in one of the 2 shops.

 

I tried copying the order-carrier.tpl so it's exact the same file. nothing worked.

Link to comment
Share on other sites

What is your Prestashop version ?

 

it look like prestashop cache issue.

Disable chache, and then do clear chache.

Check via FTP to make sure all cache files has been deleted from your Prestashop /cache/ directory or /smarty/compile/ directory

If you are use cloud service like cloudflare, make sure to clear cache on your cloud service provider side too.

Link to comment
Share on other sites

What is your Prestashop version ?

 

it look like prestashop cache issue.

Disable chache, and then do clear chache.

Check via FTP to make sure all cache files has been deleted from your Prestashop /cache/ directory or /smarty/compile/ directory

If you are use cloud service like cloudflare, make sure to clear cache on your cloud service provider side too.

Tried that already. disabled the cache completely in BO and also tried deleting it in FTP but that takes the whole day. it takes so long that it just stops deleting after a while without everything being deleted. i can try deleting it trough ssh, maybe it will be faster then.

 

Our version is PrestaShop™ 1.5.4.1 but whe can't update beceause then we probably need to change our import scripts.

 

When i looked in the database in the orders table i saw that the carrier ID was 0 when someone used the carrier we don't want.

Edited by RamsesLeroi (see edit history)
Link to comment
Share on other sites

After disabled cache and clear cache, don't forget to activate force smarty compile option to make sure the theme file is recompiled.

 

In this case, i think you don't have to delete all cache files or all smarty compiled files

But you have to make sure order-carrier.tpl compiled file was deleted

With FTP, browse to directory /cache/smarty/compile/

and then with FTP "Search" feature, you can search for a file with keyword "file.order-carrier.tpl.php" (without Quotes)

If you've found such files, you should delete it.

 

Reload front office page Order-Carrier to make sure theme file order-carrier.tpl was recompiled and the unwanted carrier was not there anymore

Link to comment
Share on other sites

After disabled cache and clear cache, don't forget to activate force smarty compile option to make sure the theme file is recompiled.

 

In this case, i think you don't have to delete all cache files or all smarty compiled files

But you have to make sure order-carrier.tpl compiled file was deleted

With FTP, browse to directory /cache/smarty/compile/

and then with FTP "Search" feature, you can search for a file with keyword "file.order-carrier.tpl.php" (without Quotes)

If you've found such files, you should delete it.

 

Reload front office page Order-Carrier to make sure theme file order-carrier.tpl was recompiled and the unwanted carrier was not there anymore

 

 

Well, i tried disabling the cache and recompiling it in the backoffice (since manuallly deleting didn't work) but nothing.

 

Also ik changed things in the order-carrier.tpl file and it was updated immediately, so i don't think it will work if i delete the cache.

 

What's strange is that 'The best price and speed' shows twice, once with the correct carrier and once with the carrier we don't want. How could they both be the cheapest if one is free and one is €7,95

Link to comment
Share on other sites

Ramses,

Does the carrier that shows up wrongly, have an ID of value = 0 in the database as well?

 

If you want, I can have a quick look in your tables to see if I see anything wrong. If you want this, please add a temporary employee (Admin->Employee), with admin rights to both your shops, and PM (Don't post here, Private Message!) the login info: login name, password, URLs to shop admin pages. Suggested employee login name: [email protected] )

 

 

pascal.

Link to comment
Share on other sites

a little bit complicated to predicting what is going wrong here, since we can't see or check directly on your prestashop.

If you are sure this is not a cache issue, then maybe this is a database issue.
Because you are familiar with phpmyadmin, then you should check following database table :

Mandatory
PREFIX_carrier
PREFIX_carrier_lang
PREFIX_carrier_zone
PREFIX_carrier_group
PREFIX_carrier_shop

Optional but affecting
PREFIX_cart_rule_carrier
PREFIX_product_carrier
PREFIX_warehouse_carrier

Won't affecting to this issue, but have a relations with your carriers
PREFIX_range_price
PREFIX_range_weight
PREFIX_delivery
PREFIX_orders
PREFIX_order_carrier
PREFIX_carrier_tax_rules_group_shop

 

---------------------------------------------------------------

Note : Default Prestashop database PREFIX is ps_

Link to comment
Share on other sites

I hope you're understand about cache and how to handle cache issue, not only prestashop cache and smarty compiled files, but includes browser cache and internet connection cache.
And i hope you're also understand about the Prestashop carriers database table in relation to this issue.

First, please make sure this isn't cache issue.

Link to comment
Share on other sites

  • 2 weeks later...

i don't have that second problem you have, maybe you should make your own topic?

 

I have hidden the extra carrier with css so it's still possible to order without shipping cost but it's a lot harder now.

 

it's just a temporary solution. if you want, iGiorgis, i can hide your second carrier with css for you.

Link to comment
Share on other sites

i don't have that second problem you have, maybe you should make your own topic?

 

I have hidden the extra carrier with css so it's still possible to order without shipping cost but it's a lot harder now.

 

it's just a temporary solution. if you want, iGiorgis, i can hide your second carrier with css for you.

thx Ramses, but i delete some old carriers from mySQL and now seems ok.

My eshop is not ready for public and with that solution seems to work ok now.

 

the only "problem" is i still dont receive the order notification at the top of admin's BO

but the email notification is ok

Link to comment
Share on other sites

  • 2 months later...

Sorry Yankee_PL. Still nothing, only the temporary hiding solution with CSS.

Maybe one day we will upgrade to 1.6 and it will be good.

 

Hmm Im on presta 1.6 so the problem still remains. I did hide with css also but it is only tempoorary as you said. Im still searching so I'l let you know when I find a solution.

 

Best Tegards.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

I had the same issue... even in 1.6.0.9... There is something in the carrier calculation logic that is creating it, but I simply cannot find it. It is definitely being generated server-side because a print_r of the return from getDeliveryOptionList() near the start of Cart::simulateCarriersOutput() has this on the end:

            [0,] => Array
                (
                    [carrier_list] => Array
                        (
                            [0] => Array
                                (
                                    [price_with_tax] =>
                                    [price_without_tax] => 0
                                    [package_list] => Array
                                        (
                                            [0] => 0
                                        )

                                    [product_list] => Array
                                        (
                                        )

                                    [instance] => Carrier Object
                                        (
                                            [id_reference] =>
                                            [name] =>
..etc.
... all zero, empty or default values, including a carrier id of 0.

 

I couldn't find where it was being created - there's a lot of complicated logic 'upstream' so I ended up adding to the end of that function:

        $c = array();
        foreach ($carriers as &$carrier)
                if (!empty($carrier['name']))
                    $c[] = $carrier; 
        return $c; //was $carriers;
 
- this sorted out the carriercompare module, but not the main shopping cart. So I pretty much gave up at that point, and just modified order-carrier.tpl to not display if there was no carrier name - here's a diff

 diff order-carrier.tpl order-carrier.tpl.bak
70a71,76
> {assign var="blankc" value="0"}
> {foreach from=$option.carrier_list key=mykey item=value name=clist}
> {if $smarty.foreach.clist.first}{if !$value.instance->name}
> {assign var="blankc" value="1"}{/if}{/if}
> {/foreach}
> {if !$blankc}
259a266
> {/if}
HTH.
Link to comment
Share on other sites

  • 6 months later...

Hi,

 

After long searching i have found the solution that works in my case.

 

The problem is in classes/cart.php. And actualy fresh version fixes it corectly but If you can't upgrade your version here is what I've copied from new version of cart.php. It starts around 1881 line:

	/**
	 * Get all deliveries options available for the current cart
	 * @param Country $default_country
	 * @param boolean $flush Force flushing cache
	 *
	 * @return array array(
	 *                   0 => array( // First address
	 *                       '12,' => array(  // First delivery option available for this address
	 *                           carrier_list => array(
	 *                               12 => array( // First carrier for this option
	 *                                   'instance' => Carrier Object,
	 *                                   'logo' => <url to the carriers logo>,
	 *                                   'price_with_tax' => 12.4,
	 *                                   'price_without_tax' => 12.4,
	 *                                   'package_list' => array(
	 *                                       1,
	 *                                       3,
	 *                                   ),
	 *                               ),
	 *                           ),
	 *                           is_best_grade => true, // Does this option have the biggest grade (quick shipping) for this shipping address
	 *                           is_best_price => true, // Does this option have the lower price for this shipping address
	 *                           unique_carrier => true, // Does this option use a unique carrier
	 *                           total_price_with_tax => 12.5,
	 *                           total_price_without_tax => 12.5,
	 *                           position => 5, // Average of the carrier position
	 *                       ),
	 *                   ),
	 *               );
	 *               If there are no carriers available for an address, return an empty  array
	 */
	public function getDeliveryOptionList(Country $default_country = null, $flush = false)
	{
		static $cache = array();
		if (isset($cache[$this->id]) && !$flush)
			return $cache[$this->id];

		$delivery_option_list = array();
		$carriers_price = array();
		$carrier_collection = array();
		$package_list = $this->getPackageList();

		// Foreach addresses
		foreach ($package_list as $id_address => $packages)
		{
			// Initialize vars
			$delivery_option_list[$id_address] = array();
			$carriers_price[$id_address] = array();
			$common_carriers = null;
			$best_price_carriers = array();
			$best_grade_carriers = array();
			$carriers_instance = array();

			// Get country
			if ($id_address)
			{
				$address = new Address($id_address);
				$country = new Country($address->id_country);
			}
			else
				$country = $default_country;

			// Foreach packages, get the carriers with best price, best position and best grade
			foreach ($packages as $id_package => $package)
			{
				// No carriers available
				if (count($packages) == 1 && count($package['carrier_list']) == 1 && current($package['carrier_list']) == 0)
				{
					$cache[$this->id] = array();
					return $cache[$this->id];
				}

				$carriers_price[$id_address][$id_package] = array();

				// Get all common carriers for each packages to the same address
				if (is_null($common_carriers))
					$common_carriers = $package['carrier_list'];
				else
					$common_carriers = array_intersect($common_carriers, $package['carrier_list']);

				$best_price = null;
				$best_price_carrier = null;
				$best_grade = null;
				$best_grade_carrier = null;

				// Foreach carriers of the package, calculate his price, check if it the best price, position and grade
				foreach ($package['carrier_list'] as $id_carrier)
				{
					if (!isset($carriers_instance[$id_carrier]))
						$carriers_instance[$id_carrier] = new Carrier($id_carrier);

					$price_with_tax = $this->getPackageShippingCost($id_carrier, true, $country, $package['product_list']);
					$price_without_tax = $this->getPackageShippingCost($id_carrier, false, $country, $package['product_list']);
					if (is_null($best_price) || $price_with_tax < $best_price)
					{
						$best_price = $price_with_tax;
						$best_price_carrier = $id_carrier;
					}
					$carriers_price[$id_address][$id_package][$id_carrier] = array(
						'without_tax' => $price_without_tax,
						'with_tax' => $price_with_tax);

					$grade = $carriers_instance[$id_carrier]->grade;
					if (is_null($best_grade) || $grade > $best_grade)
					{
						$best_grade = $grade;
						$best_grade_carrier = $id_carrier;
					}
				}

				$best_price_carriers[$id_package] = $best_price_carrier;
				$best_grade_carriers[$id_package] = $best_grade_carrier;
			}

			// Reset $best_price_carrier, it's now an array
			$best_price_carrier = array();
			$key = '';

			// Get the delivery option with the lower price
			foreach ($best_price_carriers as $id_package => $id_carrier)
			{
				$key .= $id_carrier.',';
				if (!isset($best_price_carrier[$id_carrier]))
					$best_price_carrier[$id_carrier] = array(
						'price_with_tax' => 0,
						'price_without_tax' => 0,
						'package_list' => array(),
						'product_list' => array(),
					);
				$best_price_carrier[$id_carrier]['price_with_tax'] += $carriers_price[$id_address][$id_package][$id_carrier]['with_tax'];
				$best_price_carrier[$id_carrier]['price_without_tax'] += $carriers_price[$id_address][$id_package][$id_carrier]['without_tax'];
				$best_price_carrier[$id_carrier]['package_list'][] = $id_package;
				$best_price_carrier[$id_carrier]['product_list'] = array_merge($best_price_carrier[$id_carrier]['product_list'], $packages[$id_package]['product_list']);
				$best_price_carrier[$id_carrier]['instance'] = $carriers_instance[$id_carrier];
				$real_best_price = !isset($real_best_price) || $real_best_price > $carriers_price[$id_address][$id_package][$id_carrier]['with_tax'] ?
					$carriers_price[$id_address][$id_package][$id_carrier]['with_tax'] : $real_best_price;
				$real_best_price_wt = !isset($real_best_price_wt) || $real_best_price_wt > $carriers_price[$id_address][$id_package][$id_carrier]['without_tax'] ?
					$carriers_price[$id_address][$id_package][$id_carrier]['without_tax'] : $real_best_price_wt;
			}

			// Add the delivery option with best price as best price
			$delivery_option_list[$id_address][$key] = array(
				'carrier_list' => $best_price_carrier,
				'is_best_price' => true,
				'is_best_grade' => false,
				'unique_carrier' => (count($best_price_carrier) <= 1)
			);

			// Reset $best_grade_carrier, it's now an array
			$best_grade_carrier = array();
			$key = '';

			// Get the delivery option with the best grade
			foreach ($best_grade_carriers as $id_package => $id_carrier)
			{
				$key .= $id_carrier.',';
				if (!isset($best_grade_carrier[$id_carrier]))
					$best_grade_carrier[$id_carrier] = array(
						'price_with_tax' => 0,
						'price_without_tax' => 0,
						'package_list' => array(),
						'product_list' => array(),
					);
				$best_grade_carrier[$id_carrier]['price_with_tax'] += $carriers_price[$id_address][$id_package][$id_carrier]['with_tax'];
				$best_grade_carrier[$id_carrier]['price_without_tax'] += $carriers_price[$id_address][$id_package][$id_carrier]['without_tax'];
				$best_grade_carrier[$id_carrier]['package_list'][] = $id_package;
				$best_grade_carrier[$id_carrier]['product_list'] = array_merge($best_grade_carrier[$id_carrier]['product_list'], $packages[$id_package]['product_list']);
				$best_grade_carrier[$id_carrier]['instance'] = $carriers_instance[$id_carrier];
			}

			// Add the delivery option with best grade as best grade
			if (!isset($delivery_option_list[$id_address][$key]))
				$delivery_option_list[$id_address][$key] = array(
					'carrier_list' => $best_grade_carrier,
					'is_best_price' => false,
					'unique_carrier' => (count($best_grade_carrier) <= 1)
				);
			$delivery_option_list[$id_address][$key]['is_best_grade'] = true;

			// Get all delivery options with a unique carrier
			foreach ($common_carriers as $id_carrier)
			{
				$key = '';
				$package_list = array();
				$product_list = array();
				$price_with_tax = 0;
				$price_without_tax = 0;

				foreach ($packages as $id_package => $package)
				{
					$key .= $id_carrier.',';
					$price_with_tax += $carriers_price[$id_address][$id_package][$id_carrier]['with_tax'];
					$price_without_tax += $carriers_price[$id_address][$id_package][$id_carrier]['without_tax'];
					$package_list[] = $id_package;
					$product_list = array_merge($product_list, $package['product_list']);
				}

				if (!isset($delivery_option_list[$id_address][$key]))
					$delivery_option_list[$id_address][$key] = array(
						'is_best_price' => false,
						'is_best_grade' => false,
						'unique_carrier' => true,
						'carrier_list' => array(
							$id_carrier => array(
								'price_with_tax' => $price_with_tax,
								'price_without_tax' => $price_without_tax,
								'instance' => $carriers_instance[$id_carrier],
								'package_list' => $package_list,
								'product_list' => $product_list,
							)
						)
					);
				else
					$delivery_option_list[$id_address][$key]['unique_carrier'] = (count($delivery_option_list[$id_address][$key]['carrier_list']) <= 1);
			}
		}

		$cart_rules = CartRule::getCustomerCartRules(Context::getContext()->cookie->id_lang, Context::getContext()->cookie->id_customer, true, true, false, $this);
		$result = Db::getInstance('SELECT * FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart='.$this->id);
		$cart_rules_in_cart = array();

		if (is_array($result) && count($result))
			foreach ($result as $row)
				$cart_rules_in_cart[] = $row['id_cart_rule'];

		$total_products_wt = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS);
		$total_products = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS);

		$free_carriers_rules = array();

		foreach ($cart_rules as $cart_rule)
		{
			$total_price = $cart_rule['minimum_amount_tax'] ? $total_products_wt : $total_products;
			$total_price += $cart_rule['minimum_amount_tax'] && $cart_rule['minimum_amount_shipping'] ? $real_best_price : 0;
			$total_price += !$cart_rule['minimum_amount_tax'] && $cart_rule['minimum_amount_shipping'] ? $real_best_price_wt : 0;
			if ($cart_rule['free_shipping'] && $cart_rule['carrier_restriction'] && $cart_rule['minimum_amount'] <= $total_price)
			{
				$cr = new CartRule((int)$cart_rule['id_cart_rule']);
				if (Validate::isLoadedObject($cr) &&
					$cr->checkValidity(Context::getContext(), in_array((int)$cart_rule['id_cart_rule'], $cart_rules_in_cart), false, false))
				{
					$carriers = $cr->getAssociatedRestrictions('carrier', true, false);
					if (is_array($carriers) && count($carriers) && isset($carriers['selected']))
						foreach ($carriers['selected'] as $carrier)
							if (isset($carrier['id_carrier']) && $carrier['id_carrier'])
								$free_carriers_rules[] = (int)$carrier['id_carrier'];
				}
			}
		}
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...