Post by drest341 » Sat Mar 22, 2014 6:16 am

Hi there.
I need some help with my MOD.
I inserted an extra tab in product page to estimate the shipping cost, with multiple calculations, copying accordinly the values into catalog/controller/product/product.php and catalog/language/..../product/product.php, but i 'm getting the error bellow:

Code: Select all

Notice: Undefined index: shippingArea in /var/www/vhosts/mysite.com/httpdocs/newsite/catalog/view/theme/default/template/product/product.tpl on line 353 
The form works OK and calculates the fee like i want, but when it is displayed for the first time i'm getting this Notice.
Also after push submit button system leads me back to description tab instead to stay in shipping tab.

I include part of the code in product.tpl

Code: Select all


  <!-- *********  TAB-SHIPPING **********    -->

<div id="tab-shipping" class="tab-content">
<form method="post">
<select name="shippingArea">
			<option>Selectoption>
			<option>N.Y.<option>
			<option>Paris</option>			
</select>
<input name="Submit" type="submit" value="Υπολόγισε" />
</form>
<?php
$area=$_POST['shippingArea'];
?> 
<?php
$number = preg_replace("/[^0-9]/", '', $special)/100; // ditch anything that is not a number 
echo "<br>";
$weightClean = preg_replace("/[^0-9]/", '', $weight)/100; // ditch anything that is not a number 
if ($number>=119.00 && $area=="Αττική-Πειραιάς")
	  {
	  echo "Free shippment!";
	  }
	  elseif ($number<=119.00 && $weightClean<=5.00 && $area=="Αττική-Πειραιάς")
	  {
	  echo "DHL the fee is € 2,70. ";
	  }
       ..............
        .............
?> 
  </div>
Any help will be appreciated.

Any fool can write code that a computer can understand. Good programmers write code that humans can understand ~ Martin Fowler.


User avatar
New member

Posts

Joined
Fri Feb 21, 2014 10:47 pm
Location - Athens

Post by drest341 » Sat Mar 22, 2014 3:57 pm

Sorry, I forgot to mention the version i use. Is v. 1.5.6.

Any fool can write code that a computer can understand. Good programmers write code that humans can understand ~ Martin Fowler.


User avatar
New member

Posts

Joined
Fri Feb 21, 2014 10:47 pm
Location - Athens

Post by drest341 » Sat Mar 22, 2014 9:34 pm

Finally the notice was displayed because the variable is not properly set. After insertion of code bellow everything runs OK.
Thanks to Georgi Kralev advise here http://www.dmxzone.com/go/13811/php-get ... ned-index/.

Code: Select all

<?php 
if (!isset($_POST['shippingArea']))
{
//If not isset -> set with dumy value undefine
$_POST['shippingArea'] = "undefine";
} 
?>

Any fool can write code that a computer can understand. Good programmers write code that humans can understand ~ Martin Fowler.


User avatar
New member

Posts

Joined
Fri Feb 21, 2014 10:47 pm
Location - Athens
Who is online

Users browsing this forum: No registered users and 24 guests