X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Pre-Login Shipping Calculator (https://forum.x-cart.com/showthread.php?t=6927)

BCSE 09-26-2004 12:54 PM

In skin1/main/customer/cart_totals.tpl look for this code:

Code:

<TD nowrap align="right"><FONT class="ProductPriceSmall">{if $login ne "" or $config.General.apply_default_country eq "Y" or $cart.shipping_cost gt 0}{include file="currency.tpl" value=$shipping_cost}</FONT></TD>
<TD nowrap align="right">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$shipping_cost}{else}n/a{assign var="not_logged_message" value="1"}</FONT></TD><TD>{/if}</TD>
</TR>
{/if}


There you will see the n/a that shows up. You can change that to what ever you like. OR you can take out the:

Code:

or $cart.shipping_cost gt 0

In the if, since you are having this problem with free shipping. It actually may be a bug and you may want to report it to X-cart via your help desk. Seems to me like shipping should show up as Zero if it's free, instead of n/a.

Carrie

inksticks 09-27-2004 07:23 AM

In skin1/main/customer/cart_totals.tpl I located this code:

Code:


<TD nowrap align="right"><FONT class="ProductPriceSmall">{if $login ne "" or $config.General.apply_default_country eq "Y" or $cart.shipping_cost gt 0}{include file="currency.tpl" value=$shipping_cost}</FONT></TD>
<TD nowrap align="right">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$shipping_cost}{else}n/a{assign var="not_logged_message" value="1"}</FONT></TD><TD>{/if}</TD>
</TR>
{/if}


I added
Code:

or $cart.shipping_cost eq 0
after
Code:

or $cart.shipping_cost gt 0

This fixed the n/a problem and now 0.00 is being shown instead of n/a but in the Delivery method: drop down list the prices of all methods still disappear when when free shipping is selected. This problem does not occur when a customer is logged in so I don't think it is a bug. There must be another place in the tpl that is causing this to happen. Any ideas?

doersam@hotmail.com 09-28-2004 07:03 AM

I finally managed to get this mod working clean in a 3.5.10 site. Here is what I did:

1). Uncheck the option "When a customer isn't logged in, it is presumed that he is from a default country." in General.

2). Create calculate.gif and place it in /skin1/images (you could just use the supplied go.gif).

3). Modified cart.php:
Old Code:
x_session_register("cart");
x_session_register("intershipper_rates");
x_session_register("intershipper_recalc");
x_session_unregister("secure_oid");
x_session_register("extended_userinfo");
x_session_register("anonymous_checkout");

New Code:
if(!$login){
$smarty->assign("not_logged_message","1");
}
else{
$smarty->assign("not_logged_message","0");
}

x_session_register("cart");
x_session_register("intershipper_rates");
x_session_register("intershipper_recalc");
x_session_unregister("secure_oid");
x_session_register("extended_userinfo");
x_session_register("anonymous_checkout");
x_session_register("zipcode_estimate");


if($HTTP_GET_VARS['zip_estimate'] == "clear"){
$zipcode_estimate = "";
func_header_location("cart.php");
}

if(!empty($HTTP_POST_VARS['zip_estimate'])){
$zipcode_estimate = $_POST['zip_estimate'];

$count = substr_count($zipcode_estimate,"0") + substr_count($zipcode_estimate,"1") + substr_count($zipcode_estimate,"2") + substr_count($zipcode_estimate,"3") + substr_count($zipcode_estimate,"4") + substr_count($zipcode_estimate,"5") + substr_count($zipcode_estimate,"6") + substr_count($zipcode_estimate,"7") + substr_count($zipcode_estimate,"8") + substr_count($zipcode_estimate,"9");

if($count != 5){ //checking for 5 digits
$zipcode_estimate = "";}

func_header_location("cart.php");
}
if($zipcode_estimate != ""){
$config["General"]["apply_default_country"] = "Y";
$config["General"]["default_zipcode"] = $zipcode_estimate;
$smarty->assign("estimate","NO");
}

4). Modified top.inc.php
Old Code:
if (!in_array($__key, array("HTTP_GET_VARS","HTTP_POST_VARS","HTTP_SERVE R_VARS","HTTP_ENV_VARS","HTTP_COOKIE_VARS","HTTP_P OST_FILES","__key","__val")))

New Code:
if (!in_array($__key, array("HTTP_GET_VARS","HTTP_POST_VARS","HTTP_SERVE R_VARS","HTTP_ENV_VARS","HTTP_COOKIE_VARS","HTTP_P OST_FILES","__key","__val","_GET","_POST","_SERVER ")))

5). Modified cart_totals.tpl
Added this code to the bottom of the file:
<div align=right>
{if $not_logged_message eq "1"}
{if $estimate ne "NO"}

Please enter your zip code to

calculate shipping charges.


<input type=TEXT name='zip_estimate' size=5 maxlength=5>
<input type=image alt="Calculate Shipping" src="../skin1/images/calculate.gif" border=0 align=middle name=btnCalculate >
{else}

Click here to change your shipping zip code.
{/if}
{/if}




If you use this method, make sure you back things up first! I am not a programmer, just a hacker.

Darren 10-27-2004 08:15 AM

Phil,

your solution works great. Thanks for the work!!





Quote:

Originally Posted by doersam@hotmail.com
I finally managed to get this mod working clean in a 3.5.10 site. Here is what I did:

1). Uncheck the option "When a customer isn't logged in, it is presumed that he is from a default country." in General.

2). Create calculate.gif and place it in /skin1/images (you could just use the supplied go.gif).

3). Modified cart.php:
Old Code:
x_session_register("cart");
x_session_register("intershipper_rates");
x_session_register("intershipper_recalc");
x_session_unregister("secure_oid");
x_session_register("extended_userinfo");
x_session_register("anonymous_checkout");

New Code:
if(!$login){
$smarty->assign("not_logged_message","1");
}
else{
$smarty->assign("not_logged_message","0");
}

x_session_register("cart");


x_session_register("intershipper_rates");
x_session_register("intershipper_recalc");
x_session_unregister("secure_oid");
x_session_register("extended_userinfo");
x_session_register("anonymous_checkout");
x_session_register("zipcode_estimate");


if($HTTP_GET_VARS['zip_estimate'] == "clear"){
$zipcode_estimate = "";
func_header_location("cart.php");
}

if(!empty($HTTP_POST_VARS['zip_estimate'])){
$zipcode_estimate = $_POST['zip_estimate'];

$count = substr_count($zipcode_estimate,"0") + substr_count($zipcode_estimate,"1") + substr_count($zipcode_estimate,"2") + substr_count($zipcode_estimate,"3") + substr_count($zipcode_estimate,"4") + substr_count($zipcode_estimate,"5") + substr_count($zipcode_estimate,"6") + substr_count($zipcode_estimate,"7") + substr_count($zipcode_estimate,"8") + substr_count($zipcode_estimate,"9");

if($count != 5){ //checking for 5 digits
$zipcode_estimate = "";}

func_header_location("cart.php");
}
if($zipcode_estimate != ""){
$config["General"]["apply_default_country"] = "Y";
$config["General"]["default_zipcode"] = $zipcode_estimate;
$smarty->assign("estimate","NO");
}

4). Modified top.inc.php
Old Code:
if (!in_array($__key, array("HTTP_GET_VARS","HTTP_POST_VARS","HTTP_SERVE R_VARS","HTTP_ENV_VARS","HTTP_COOKIE_VARS","HTTP_P OST_FILES","__key","__val")))

New Code:
if (!in_array($__key, array("HTTP_GET_VARS","HTTP_POST_VARS","HTTP_SERVE R_VARS","HTTP_ENV_VARS","HTTP_COOKIE_VARS","HTTP_P OST_FILES","__key","__val","_GET","_POST","_SERVER ")))

5). Modified cart_totals.tpl
Added this code to the bottom of the file:
<div align=right>
{if $not_logged_message eq "1"}
{if $estimate ne "NO"}

Please enter your zip code to

calculate shipping charges.


<input type=TEXT name='zip_estimate' size=5 maxlength=5>
<input type=image alt="Calculate Shipping" src="../skin1/images/calculate.gif" border=0 align=middle name=btnCalculate >
{else}

Click here to change your shipping zip code.
{/if}
{/if}




If you use this method, make sure you back things up first! I am not a programmer, just a hacker.


sportruck 12-08-2004 03:21 PM

I have this working in 4.0.8, and want to have it display the ZIP code that the customer entered. Any ideas?

BCSE 12-08-2004 03:54 PM

Quote:

Originally Posted by sportruck
I have this working in 4.0.8, but I would like to have it display the ZIP code that the customer entered. I tried using the variables, but it does not seem to work. Anyone have any ideas?


To display any php variable in smarty, you first have to tell php to make it available for smarty. So you would need

$smarty->assign("zipcode_estimate",$zipcode_estimate);

in cart.php (usually near the end of the file with the rest of the smarty assigns).

That makes {$zipcode_estimate} available in the templates.

HTH!

Carrie

sportruck 12-08-2004 04:10 PM

Thank you. I had firgued out the session variables and was editing my original post before I saw your reply.

I also made it calculate tax based on ZIP code, but I hard coded it for CA tax. I'm sure there is a better way to do this, but this is my quick hack:

Code:

      if($zipcode_estimate >= 90001 && $zipcode_estimate <= 96162){
            $config["General"]["default_state"] = "CA";
      }


chilll33 12-08-2004 05:30 PM

Quote:

Originally Posted by sportruck

I also made it calculate tax based on ZIP code, but I hard coded it for CA tax. I'm sure there is a better way to do this, but this is my quick hack:

Code:

      if($zipcode_estimate >= 90001 && $zipcode_estimate <= 96162){
            $config["General"]["default_state"] = "CA";
      }



I did the same for pre-login shipping and tax for florida, it works great

halestorm 12-14-2004 03:12 PM

I'm using 4.08. There is so much code on all these pages, I'm not sure where to begin. If anybody could just PM me from start to finish I would really appreciate it.

Thaks!

Daniel

dalmuti 12-20-2004 05:11 PM

I would hope they would post it here for all of us. ;-)

Louise

BCSE 12-20-2004 05:18 PM

My first long post on page 5 dated "Thu Sep 23, 2004 1:36 pm" is all the code and steps I used for version 4.0.4 that has been since upgraded to I believe 4.0.7 and it works in there too.

Carrie

halestorm 01-14-2005 10:09 AM

ok so I used the code in

http://forum.x-cart.com/viewtopic.php?p=59671#59671

and so far it seems to work. I'm in 4.8

Just one other thing...

On the page right about where it asks for the zip code, it says, "Please log in to see shipping rates.:
anonymous"

How can I remove that?

Jayk 03-02-2005 09:09 PM

Has anyone tried this mod with 4.0.12?

I might give it a try anyway, but I've only got a live shop, no test server.

Thanks,

Jason

chilll33 03-03-2005 04:40 AM

Quote:

Originally Posted by Jayk
Has anyone tried this mod with 4.0.12?

I might give it a try anyway, but I've only got a live shop, no test server.

Thanks,

Jason



Works for me

Jayk 03-03-2005 09:14 AM

Thanks for the reply. I'll give it a shot then.

Jason

Jayk 03-04-2005 05:27 PM

Just installed the mod on 4.0.12 Gold and it works like a dream.

Thanks,

Jason

Sonia 03-11-2005 05:42 AM

Hey people! This looks like a great Mod, but I'm running into a glitch. BCSE came up with this mod for Canada shipping calculations (A big thanks, Carrie and everyone else who take the time to share mods) ...

http://forum.x-cart.com/viewtopic.php?p=59711#59711

I'm using Canada Post for now. When I change the country to Canada, the drop down menu for shipping rates changes to International. When I type in a postal code, that menu changes to US shipping rates. I'm confused. I'm assuming it's something to do with the Cart.php code, but I'm not familiar enough with PHP to know what to change.

Here's a link to a product on my website for you to test the shipping calculator on (site's not live yet - soon, very soon...I hope :wink: )
http://www.vidaville.com/store/product.php?productid=16291&cat=320&page=1

Help anyone? Carrie? adpboss, did you get this working?

Edit:
Okay, I got it so the Canadian Shipping rate is calculated. But now when I put in a US postal Code it says:

Quote:

Canada Post Realtime shipping rate calculation service returned the following error:
Destination Postal Code/State Name/ Country is illegal.
Sorry, there are no available shipping methods for your location.:
anonymous

Anyone know what that means? Is there a setting somewhere I've missed?

Holy smokes this stuff seems so complicated!!! :x

Sonia

KCAutosound 03-11-2005 03:24 PM

Hey guys I'm running version 4.0.12 Could someone PM me the code for this. The code seems to be spread out over 7 pages.

micromedia 03-17-2005 07:20 PM

Hi,

This is good mod . Thank you very much. I am running on 4.0.11. it is working fine.
I am selling Out of United states and other countries. Some Country I will not ship. And I am using UPS.

I am using this code:
Code:

{* BCSE Begin *}
{if $login}
{else}
  {if $estimate ne "NO"}
       
Enter your zip/postal code to calculate shipping charges.

        <select name='country_estimate'>
        <option value="US">United States
        <option value="CA">Canada
        </select>
       

      <input type=TEXT name='zip_estimate' size=6 maxlength=6>
      {include file="buttons/button.tpl" button_title="Calculate Shipping" href="javascript: document.cartform.submit()"  js_to_href="Y"}
     
      {else}

Click here to change your zip code

    {/if}
   


{/if}
{* BCSE End *}



But I have to add my available country
on this code:
Code:

<select name='country_estimate'>
        <option value="US">United States</OPTION>
        <option value="CA">Canada</OPTION>
                <OPTION value="AF">Afghanistan</OPTION>
<OPTION value="AL">Albania</OPTION>
<OPTION value="DZ">Algeria</OPTION>
<OPTION value="AS">American Samoa</OPTION>
<OPTION value="AD">Andorra</OPTION>
<OPTION value="AO">Angola</OPTION>
<OPTION value="AI">Anguilla</OPTION>
<OPTION value="AQ">Antarctica</OPTION>
<OPTION value="AG">Antigua and Barbuda</OPTION>
<OPTION value="AR">Argentina</OPTION>
<OPTION value="AM">Armenia</OPTION>
<OPTION value="AW">Aruba</OPTION>
<OPTION value="AU">Australia</OPTION>
<OPTION value="AT">Austria</OPTION>
<OPTION value="AZ">Azerbaijan</OPTION>
<OPTION value="BS">Bahamas</OPTION>
<OPTION value="BH">Bahrain</OPTION>
<OPTION value="BD">Bangladesh</OPTION>
<OPTION value="BB">Barbados</OPTION>
<OPTION value="BY">Belarus</OPTION>
<OPTION value="BE">Belgium</OPTION>
<OPTION value="BZ">Belize</OPTION>
<OPTION value="BJ">Benin</OPTION>
<OPTION value="BM">Bermuda</OPTION>
<OPTION value="BT">Bhutan</OPTION>
<OPTION value="BO">Bolivia</OPTION>
<OPTION value="BA">Bosnia and Herzegowina</OPTION>
<OPTION value="BW">Botswana</OPTION>
<OPTION value="BV">Bouvet Island</OPTION>
<OPTION value="BR">Brazil</OPTION>
<OPTION value="IO">British Indian Ocean Territory</OPTION>
<OPTION value="VG">British Virgin Islands</OPTION>
<OPTION value="BN">Brunei Darussalam</OPTION>
<OPTION value="BG">Bulgaria</OPTION>
<OPTION value="BF">Burkina Faso</OPTION>
<OPTION value="BI">Burundi</OPTION>
<OPTION value="KH">Cambodia</OPTION>
<OPTION value="CM">Cameroon</OPTION>
<OPTION value="CA">Canada</OPTION>
<OPTION value="CV">Cape Verde</OPTION>
<OPTION value="KY">Cayman Islands</OPTION>
<OPTION value="CF">Central African Republic</OPTION>
<OPTION value="TD">Chad</OPTION>
<OPTION value="CL">Chile</OPTION>
<OPTION value="CN">China</OPTION>
<OPTION value="CX">Christmas Island</OPTION>
<OPTION value="CC">Cocos (Keeling) Islands</OPTION>
<OPTION value="CO">Colombia</OPTION>
<OPTION value="KM">Comoros</OPTION>
<OPTION value="CG">Congo</OPTION>
<OPTION value="CK">Cook Islands</OPTION>
<OPTION value="CR">Costa Rica</OPTION>
<OPTION value="CI">Cote D'ivoire</OPTION>
<OPTION value="HR">Croatia</OPTION>
<OPTION value="CU">Cuba</OPTION>
<OPTION value="CY">Cyprus</OPTION>
<OPTION value="CZ">Czech Republic</OPTION>
<OPTION value="DK">Denmark</OPTION>
<OPTION value="DJ">Djibouti</OPTION>
<OPTION value="DM">Dominica</OPTION>
<OPTION value="DO">Dominican Republic</OPTION>
<OPTION value="TP">East Timor</OPTION>
<OPTION value="EC">Ecuador</OPTION>
<OPTION value="EG">Egypt</OPTION>
<OPTION value="SV">El Salvador</OPTION>
<OPTION value="GQ">Equatorial Guinea</OPTION>
<OPTION value="ER">Eritrea</OPTION>
<OPTION value="EE">Estonia</OPTION>
<OPTION value="ET">Ethiopia</OPTION>
<OPTION value="FK">Falkland Islands (Malvinas)</OPTION>
<OPTION value="FO">Faroe Islands</OPTION>
<OPTION value="FJ">Fiji</OPTION>
<OPTION value="FI">Finland</OPTION>
<OPTION value="FR">France</OPTION>
<OPTION value="FX">France, Metropolitan</OPTION>
<OPTION value="GF">French Guiana</OPTION>
<OPTION value="PF">French Polynesia</OPTION>
<OPTION value="TF">French Southern Territories</OPTION>
<OPTION value="GA">Gabon</OPTION>
<OPTION value="GM">Gambia</OPTION>
<OPTION value="GE">Georgia</OPTION>
<OPTION value="DE">Germany</OPTION>
<OPTION value="GH">Ghana</OPTION>
<OPTION value="GI">Gibraltar</OPTION>
<OPTION value="GR">Greece</OPTION>
<OPTION value="GL">Greenland</OPTION>
<OPTION value="GD">Grenada</OPTION>
<OPTION value="GP">Guadeloupe</OPTION>
<OPTION value="GU">Guam</OPTION>
<OPTION value="GT">Guatemala</OPTION>
<OPTION value="GN">Guinea</OPTION>
<OPTION value="GW">Guinea-Bissau</OPTION>
<OPTION value="GY">Guyana</OPTION>
<OPTION value="HT">Haiti</OPTION>
<OPTION value="HM">Heard and McDonald Islands</OPTION>
<OPTION value="HN">Honduras</OPTION>
<OPTION value="HK">Hong Kong</OPTION>
<OPTION value="HU">Hungary</OPTION>
<OPTION value="IS">Iceland</OPTION>
<OPTION value="IN">India</OPTION>
<OPTION value="ID">Indonesia</OPTION>
<OPTION value="IQ">Iraq</OPTION>
<OPTION value="IE">Ireland</OPTION>
<OPTION value="IR">Islamic Republic of Iran</OPTION>
<OPTION value="IL">Israel</OPTION>
<OPTION value="IT">Italy</OPTION>
<OPTION value="JM">Jamaica</OPTION>
<OPTION value="JP">Japan</OPTION>
<OPTION value="JO">Jordan</OPTION>
<OPTION value="KZ">Kazakhstan</OPTION>
<OPTION value="KE">Kenya</OPTION>
<OPTION value="KI">Kiribati</OPTION>
<OPTION value="KP">Korea</OPTION>
<OPTION value="KR">Korea, Republic of</OPTION>
<OPTION value="KW">Kuwait</OPTION>
<OPTION value="KG">Kyrgyzstan</OPTION>
<OPTION value="LA">Laos</OPTION>
<OPTION value="LV">Latvia</OPTION>
<OPTION value="LB">Lebanon</OPTION>
<OPTION value="LS">Lesotho</OPTION>
<OPTION value="LR">Liberia</OPTION>
<OPTION value="LY">Libyan Arab Jamahiriya</OPTION>
<OPTION value="LI">Liechtenstein</OPTION>
<OPTION value="LT">Lithuania</OPTION>
<OPTION value="LU">Luxembourg</OPTION>
<OPTION value="MO">Macau</OPTION>
<OPTION value="MK">Macedonia</OPTION>
<OPTION value="MG">Madagascar</OPTION>
<OPTION value="MW">Malawi</OPTION>
<OPTION value="MY">Malaysia</OPTION>
<OPTION value="MV">Maldives</OPTION>
<OPTION value="ML">Mali</OPTION>
<OPTION value="MT">Malta</OPTION>
<OPTION value="MH">Marshall Islands</OPTION>
<OPTION value="MQ">Martinique</OPTION>
<OPTION value="MR">Mauritania</OPTION>
<OPTION value="MU">Mauritius</OPTION>
<OPTION value="YT">Mayotte</OPTION>
<OPTION value="MX">Mexico</OPTION>
<OPTION value="FM">Micronesia</OPTION>
<OPTION value="MD">Moldova, Republic of</OPTION>
<OPTION value="MC">Monaco</OPTION>
<OPTION value="MN">Mongolia</OPTION>
<OPTION value="MS">Montserrat</OPTION>
<OPTION value="MA">Morocco</OPTION>
<OPTION value="MZ">Mozambique</OPTION>
<OPTION value="MM">Myanmar</OPTION>
<OPTION value="NA">Namibia</OPTION>
<OPTION value="NR">Nauru</OPTION>
<OPTION value="NP">Nepal</OPTION>
<OPTION value="NL">Netherlands</OPTION>
<OPTION value="AN">Netherlands Antilles</OPTION>
<OPTION value="NC">New Caledonia</OPTION>
<OPTION value="NZ">New Zealand</OPTION>
<OPTION value="NI">Nicaragua</OPTION>
<OPTION value="NE">Niger</OPTION>
<OPTION value="NG">Nigeria</OPTION>
<OPTION value="NU">Niue</OPTION>
<OPTION value="NF">Norfolk Island</OPTION>
<OPTION value="MP">Northern Mariana Islands</OPTION>
<OPTION value="NO">Norway</OPTION>
<OPTION value="OM">Oman</OPTION>
<OPTION value="PK">Pakistan</OPTION>
<OPTION value="PW">Palau</OPTION>
<OPTION value="PA">Panama</OPTION>
<OPTION value="PG">Papua New Guinea</OPTION>
<OPTION value="PY">Paraguay</OPTION>
<OPTION value="PE">Peru</OPTION>
<OPTION value="PH">Philippines</OPTION>
<OPTION value="PN">Pitcairn</OPTION>
<OPTION value="PL">Poland</OPTION>
<OPTION value="PT">Portugal</OPTION>
<OPTION value="PR">Puerto Rico</OPTION>
<OPTION value="QA">Qatar</OPTION>
<OPTION value="RE">Reunion</OPTION>
<OPTION value="RO">Romania</OPTION>
<OPTION value="RU">Russian Federation</OPTION>
<OPTION value="RW">Rwanda</OPTION>
<OPTION value="LC">Saint Lucia</OPTION>
<OPTION value="WS">Samoa</OPTION>
<OPTION value="SM">San Marino</OPTION>
<OPTION value="ST">Sao Tome and Principe</OPTION>
<OPTION value="SA">Saudi Arabia</OPTION>
<OPTION value="SN">Senegal</OPTION>
<OPTION value="SC">Seychelles</OPTION>
<OPTION value="SL">Sierra Leone</OPTION>
<OPTION value="SG">Singapore</OPTION>
<OPTION value="SK">Slovakia</OPTION>
<OPTION value="SI">Slovenia</OPTION>
<OPTION value="SB">Solomon Islands</OPTION>
<OPTION value="SO">Somalia</OPTION>
<OPTION value="ZA">South Africa</OPTION>
<OPTION value="ES">Spain</OPTION>
<OPTION value="LK">Sri Lanka</OPTION>
<OPTION value="SH">St. Helena</OPTION>
<OPTION value="KN">St. Kitts and Nevis</OPTION>
<OPTION value="PM">St. Pierre and Miquelon</OPTION>
<OPTION value="VC">St. Vincent and the Grenadines</OPTION>
<OPTION value="SD">Sudan</OPTION>
<OPTION value="SR">Suriname</OPTION>
<OPTION value="SJ">Svalbard and Jan Mayen Islands</OPTION>
<OPTION value="SZ">Swaziland</OPTION>
<OPTION value="SE">Sweden</OPTION>
<OPTION value="CH">Switzerland</OPTION>
<OPTION value="SY">Syrian Arab Republic</OPTION>
<OPTION value="TW">Taiwan</OPTION>
<OPTION value="TJ">Tajikistan</OPTION>
<OPTION value="TZ">Tanzania, United Republic of</OPTION>
<OPTION value="TH">Thailand</OPTION>
<OPTION value="TG">Togo</OPTION>
<OPTION value="TK">Tokelau</OPTION>
<OPTION value="TO">Tonga</OPTION>
<OPTION value="TT">Trinidad and Tobago</OPTION>
<OPTION value="TN">Tunisia</OPTION>
<OPTION value="TR">Turkey</OPTION>
<OPTION value="TM">Turkmenistan</OPTION>
<OPTION value="TC">Turks and Caicos Islands</OPTION>
<OPTION value="TV">Tuvalu</OPTION>
<OPTION value="UG">Uganda</OPTION>
<OPTION value="UA">Ukraine</OPTION>
<OPTION value="AE">United Arab Emirates</OPTION>
<OPTION value="GB">United Kingdom (Great Britain)</OPTION>
<OPTION value="US"selected>United States</OPTION>
<OPTION value="VI">United States Virgin Islands</OPTION>
<OPTION value="UY">Uruguay</OPTION>
<OPTION value="UZ">Uzbekistan</OPTION>
<OPTION value="VU">Vanuatu</OPTION>
<OPTION value="VA">Vatican City State</OPTION>
<OPTION value="VE">Venezuela</OPTION>
<OPTION value="VN">Viet Nam</OPTION>
<OPTION value="WF">Wallis And Futuna Islands</OPTION>
<OPTION value="EH">Western Sahara</OPTION>
<OPTION value="YE">Yemen</OPTION>
<OPTION value="YU">Yugoslavia</OPTION>
<OPTION value="ZR">Zaire</OPTION>
<OPTION value="ZM">Zambia</OPTION>
<OPTION value="ZW">Zimbabwe</OPTION>        </select>

etc.

How can I change this code with my available country? When I disable country on my admin page I want to change automatickly this <option> line .

IS it possible?

Thanks...








Quote:

Originally Posted by BCSE
Try this adpboss. ;) I have this working in 4.0.4 for US and Canada realtime shipping. I tested this for FedEx only as I don't have USPS account or UPS account.

In cart.php After:
Code:

x_session_register("cart");
x_session_register("intershipper_rates");
x_session_register("intershipper_recalc");
x_session_unregister("secure_oid");
x_session_register("extended_userinfo");
x_session_register("anonymous_checkout");
x_session_register("payment_cc_fields");
x_session_register("current_carrier");


Insert:
Code:

# BCSE

x_session_register("zipcode_estimate");
x_session_register("default_country_estimate");

if($zip_estimate == "clear")
{
      $zipcode_estimate = "";
      func_header_location("cart.php");
}
 
if(!empty($zip_estimate))
{
      $zipcode_estimate = $zip_estimate;
     
      $default_country_estimate= $country_estimate;
   
    if($country_estimate == "US")
    {
              $count = substr_count($zipcode_estimate,"0") + substr_count($zipcode_estimate,"1") + substr_count($zipcode_estimate,"2") + substr_count($zipcode_estimate,"3") + substr_count($zipcode_estimate,"4") + substr_count($zipcode_estimate,"5") + substr_count($zipcode_estimate,"6") + substr_count($zipcode_estimate,"7") + substr_count($zipcode_estimate,"8") + substr_count($zipcode_estimate,"9");
             
              if($count != 5)  //checking for 5 digits
          $zipcode_estimate = "";
             
    }
        if($country_estimate == "CA" && strlen($zipcode_estimate)!=6)
                $zipcode_estimate= "";
     
      if($mode=="checkout")
        func_header_location("cart.php?mode=checkout");
      else     
        func_header_location("cart.php");
}
if($zipcode_estimate != "")
{
        $config["General"]["default_country"] = $default_country_estimate;
      $config["General"]["apply_default_country"] = "Y";
   
      $config["General"]["default_zipcode"] = $zipcode_estimate;
     
   
      $smarty->assign("estimate","NO");
}

# BCSE


Then in skin1/customer/main/cart_totals.tpl Before:
Code:

{if $not_logged_message eq "1"}{$lng.txt_order_total_msg}{/if}


Insert:
Code:

{* BCSE Begin *}
{if $login}
{else}
  {if $estimate ne "NO"}
       
Enter your zip/postal code to calculate shipping charges.

        <select name='country_estimate'>
        <option value="US">United States
        <option value="CA">Canada
        </select>
       

      <input type=TEXT name='zip_estimate' size=6 maxlength=6>
      {include file="buttons/button.tpl" button_title="Calculate Shipping" href="javascript: document.cartform.submit()"  js_to_href="Y"}
     
      {else}

Click here to change your zip code

    {/if}
   


{/if}
{* BCSE End *}


You owe me a beer if this works adpboss ;)

Carrie



g0t0pless 03-17-2005 08:49 PM

Awesome!

Now, quick question. Lets see if we can expand on this mod slightly.

I would like a "calculate shipping" button on each item's description, preferably near the price somewhere. Or better yet, right above or below the "add to cart" button.

DogByteMan 03-18-2005 07:07 AM

One other thing that has come up with this mod...

If you have a value in Shipping freight ($) it is not added to the shipping amount shown but is added at checkout. This confuses the customer. Anyone know how we could add whatever value that is in Shipping freight ($) to the pre-login shipping calculation?

shwekhaw 03-21-2005 07:39 PM

I like to have this feature on my site. But I use "Defined shipping methods" ( I define shipping rate by zones) plus "FedEx Priority". I have fedex rate sheet downloaded.

I cannot use the code posted in this thread. Does this code work with UPS only? I am not sure how zipcode lookup is done in my case. I define zones by states only but I have FedEx rate sheet with zipcode.

Can someone edit posted code so that it works for my case? I do not need a fancy zipcode lookup. All I need is the code that will lookup the state entered or zone entered and calculate the shipping according to defined shipping rate.

S-H-W-E-K-H-A-W

hooter 03-21-2005 07:59 PM

Just had to say thank you to rack-it for the original concept and Carrie for the 4.x series code modifications. 8)

I just installed this for a client's shop as well as my Mom's shop over the weekend. Needless to say both are extremely pleased with this addition. :)
Thank you rack-it and Carrie.

Note to Carrie: someone is on their way over to get your reward points mod - you'll know them when you see it 8)

nfc5382 04-01-2005 10:34 AM

works great on 3.5.14, thanks!

dgrif 04-16-2005 07:07 PM

How many beers you want? It just worked for me.
Thanks a million. I didn't break anything I found yet LOL

Delores

dgrif 04-16-2005 07:19 PM

I spoke too soon. I broke my check box if the shiping address is the same as billing address. I'll buy the beer anyway LOL

Delores

chilll33 04-23-2005 05:59 PM

Can the /admin/main/test_shippings.tpl be modified or implemented to work like/with this mod?
I like the idea of using the x-cart enabled countries to check for rates.

RQJay 04-27-2005 02:25 PM

Was wondering if it would be possible for the shipping calculator to show up on the product page, so shipping can be estimated BEFORe having to place it in the cart?

rackit 05-18-2005 11:42 AM

Woah, it's been a while since I last checked this thread. EIGHT pages now, amazing!

Jayk 05-27-2005 08:32 AM

Upgraded from 4.0.12 to 4.0.13 and re-did the mod. Although it worked beautifully for 4.0.12, it broke on 4.0.13.

Jason

jedak 05-28-2005 12:23 PM

This is a great mod thanks to all who contributed.
=D> =D>
I've added the shipping part of this mod into 4.0.13 but wanted to also include the taxes can someone please provide some guidence as to where to place the taxes code in cart.php and/or cart_total.tpl
Thanks again.

jimmy_ 05-29-2005 10:27 AM

Quote:

Originally Posted by shwekhaw
I like to have this feature on my site. But I use "Defined shipping methods" ( I define shipping rate by zones) plus "FedEx Priority". I have fedex rate sheet downloaded.

I cannot use the code posted in this thread. Does this code work with UPS only? I am not sure how zipcode lookup is done in my case. I define zones by states only but I have FedEx rate sheet with zipcode.

Can someone edit posted code so that it works for my case? I do not need a fancy zipcode lookup. All I need is the code that will lookup the state entered or zone entered and calculate the shipping according to defined shipping rate.

S-H-W-E-K-H-A-W



We also use DEFINED SHIPPING Rates that are state and country specific, we were very much hoping we could use this mod with our setup. It seems everyone else here is using it for the REAL TIME SHIPPING but what about those of us who do not use real time?


We would also be interested in Tax calculations as well, so our client knows exactly what they are paying before they go any further into the checkout process.


BTW we are running 4.0.13

If anyone can help with this, we would be more then happy to compensate you for your time :)

TJ Stephens 05-31-2005 04:12 PM

This is a great mod! It should be integrated into future versions of x-cart. Thanks Rackit and all that contributed. I have the code posted by BCSE on page five working on 4.0.13 along with the tax modification posted by sportruck but I cannot figure out how to fix one problem.

I currently ship with UPS using realtime shipping costs. I also have defined another shipping option named "Customer Pick Up" so customers can pick the items up from our store without paying for shipping.

When a customer first comes to the site and inputs their zip code it displays UPS in the "select a carrier" box and the realtime shipping costs for the UPS delivery methods I have set up. That works great. If I select "Other Carriers", then it will show the defined shipping method "Customer Pick Up" that I created and the shipping cost will display n/a. That works great too.

However, once I select "Other Carriers" it will not let me go back to UPS. The "select a carrier" box disappears and only my "Customer Pick Up" option is displayed in the delivery box. Does anyone know what is causing this?

Interestingly, if I click on "Click here to change your zip code" it will display the UPS otions in the delivery box along with my customer pick up option but it does not show the realtime rates.

I hope this makes sense. Any help would be appreciated.

jeanne 06-02-2005 08:52 AM

taxes & defined rates 4.0.13
 
I use 4.0.13 with this mod and it works fine.
Right now I have Defined Shipping Rates and it works with them as well.

The taxes show up correctly on cart.php.
Define your tax zones by zip code and make sure that you do not have Default ZipCode (in General Settings) that would cause tax to be applied. I have it blank.

jedak 06-02-2005 11:14 PM

Re: taxes & defined rates 4.0.13
 
Quote:

Originally Posted by jeanne
The taxes show up correctly on cart.php.
Define your tax zones by zip code and make sure that you do not have Default ZipCode (in General Settings) that would cause tax to be applied. I have it blank.

I've tried all that you have said but still no luck were in cart.php should this code be place
Code:

if($zipcode_estimate >= 10002 && $zipcode_estimate <= 14925){
            $config["General"]["default_state"] = "NY";     
}

before or after the chipping calculation code or somewhere else.
thx

jeanne 06-03-2005 12:30 PM

I don't have code like that in cart.php. The code is already set up to do this if your tax zone is set up by zip code.
I have my destination zone (that I use for taxing) set up by zip code like this:
90%
91%
92%
93%
94%
95%
960%
961%
This mod is basically giving a temporary value to the 'Default Zip Code' entry that you can set in General Settings.
So when an zip code entry is put in the shipping calculator that matches my tax zone, the tax shows up as long as the 'Default Zip Code' entry in General Settings blank. If you have any other of the default settings (zip code, state) filled in clear the entries to see if that makes a difference.

jedak 06-04-2005 08:34 AM

Quote:

Originally Posted by jeanne
I have my destination zone (that I use for taxing) set up by zip code like this:
90%
91%
92%
93%
94%
95%
960%
961%
This mod is basically giving a temporary value to the 'Default Zip Code' entry that you can set in General Settings.
So when an zip code entry is put in the shipping calculator that matches my tax zone, the tax shows up as long as the 'Default Zip Code' entry in General Settings blank. If you have any other of the default settings (zip code, state) filled in clear the entries to see if that makes a difference.

:? :?
I 'm not sure how and where you got % in there. I remove the zipcode and city in general settings but no luck, I tried to remove the state but there is no blank option. The assign shipping is displayed in the shipping label
e.g. Sales Tax 8.625%: n/a or Sales Tax 9.50%: n/a
but the calculation is not made 'n/a' is always displayed. for some reason its not being allow to change 'n/a' to display calulated taxes. :(

Here is a look at my cart.php maybe you can see something that I couldn't.
Code:

#
# $Id: cart.php,v 1.6.2.45 2005/03/28 06:12:46 max Exp $
#
# This script implements shopping cart facility
#

require "./auth.php";
include $xcart_dir."/shipping/shipping.php";

//include "./nocookie_warning.php";

x_session_register("cart");
x_session_register("intershipper_rates");
x_session_register("intershipper_recalc");
x_session_unregister("secure_oid");
x_session_register("extended_userinfo");
x_session_register("anonymous_checkout");
x_session_register("payment_cc_fields");
x_session_register("current_carrier","UPS");
x_session_register("is_sns_action");

x_session_register("zipcode_estimate");

if($zip_estimate == "clear")
{
      $zipcode_estimate = "";
      func_header_location("cart.php");
}
   
if(!empty($zip_estimate))
{
      $zipcode_estimate = $zip_estimate;
     
      $count = substr_count($zipcode_estimate,"0") + substr_count($zipcode_estimate,"1") + substr_count($zipcode_estimate,"2") + substr_count($zipcode_estimate,"3") + substr_count($zipcode_estimate,"4") + substr_count($zipcode_estimate,"5") + substr_count($zipcode_estimate,"6") + substr_count($zipcode_estimate,"7") + substr_count($zipcode_estimate,"8") + substr_count($zipcode_estimate,"9");

      if($count != 5){  //checking for 5 digits
          $zipcode_estimate = "";}
      if($mode=="checkout")
        func_header_location("cart.php?mode=checkout");
      else       
        func_header_location("cart.php");
}
if($zipcode_estimate != "")
{
      $config["General"]["apply_default_country"] = "Y";
      $config["General"]["default_zipcode"] = $zipcode_estimate;
      $smarty->assign("estimate","NO");
}

if($zipcode_estimate >= 10001 && $zipcode_estimate <= 14975){
            $config["General"]["default_state"] = "NY";
}

$intershipper_recalc = "Y";

x_session_register("arb_account_used");
x_session_register("airborne_account");

function check_payment_methods($membership) {
        global $sql_tbl, $config, $cart;

        $gc_condition = ((@empty($cart["products"]) && @!empty($cart["giftcerts"]))?" AND pm.paymentid != 14 ":"");
        $payment_methods=func_query("select pm.*,cc.module_name,cc.processor,cc.type from $sql_tbl[payment_methods] as pm left join $sql_tbl[ccprocessors] as cc on pm.paymentid=cc.paymentid where pm.active='Y' AND (pm.membership='' OR  pm.membership='$membership') $gc_condition order by pm.orderby");
       
        $payment_methods = test_payment_methods($payment_methods,($config["General"]["hide_disfunctional_payments"]=="Y"));
       
        return $payment_methods;
}

#
# Stop list module: check transaction
#
if (!empty($active_modules["Stop_List"]) and !func_is_allowed_trans()) {
        if($mode == "checkout" || $mode == "auth") {
                $top_message["content"] = func_get_langvar_by_name("txt_stop_list_customer_note");       
                $top_message["type"] = "E";
                func_header_location("cart.php");
        }
        $smarty->assign("unallowed_transaction", "Y");
}

#
# Normalize cart content
#
if(!func_is_cart_empty($cart) && $REQUEST_METHOD == 'GET' && !in_array($mode, array('wishlist','wl2cart'))) {
        $hash = array();
        if(!empty($cart['products'])) {
                foreach($cart['products'] as $k => $p) {
                        if($p['hidden'] || !empty($p['pconf_data']))
                                continue;
                        $po = (!empty($p['options']) && is_array($p['options'])?serialize($p['options']):"");
                        $key = $p['productid'].$po.$p['free_price'];
                        if(isset($hash[$key])) {
                                if(empty($p['distribution'])) {
                                        $cart['products'][$hash[$key]]['amount'] += $p['amount'];
                                } else {
                                        $cart['products'][$hash[$key]]['amount'] = 1;
                                }
                                unset($cart['products'][$k]);
                        } else {
                                $hash[$key] = $k;
                        }
                }
        }
        unset($hash);
}

if ($mode == "checkout" || $mode == "auth") {
#
# Calculate total number of checkout process steps
#
        $total_checkout_steps = 2;
        $checkout_step_modifier["anonymous"] = 0;
        $checkout_step_modifier["payment_methods"] = 0;
        if ($login == "" or $anonymous_checkout) {
                $total_checkout_steps++;
                $checkout_step_modifier["anonymous"] = 1;
        }
        $payment_methods = check_payment_methods(@$user_account["membership"]);
        if(empty($payment_methods)) {
                $top_message['content'] = func_get_langvar_by_name("txt_no_payment_methods");
                $top_message['type'] = 'E';
                func_header_location("cart.php");
        } elseif (count($payment_methods) == 1) {
                $total_checkout_steps--;
                $checkout_step_modifier["payment_methods"] = 1;
        }
}
else
        $anonymous_checkout = false;

#
# $order_secureid (for security reasons)
#
x_session_register("order_secureid");

if ($mode == "clear_cart") {
        if(!empty($active_modules['SnS_connector']) && !empty($cart['products'])) {
                foreach($cart['products'] as $p) {
                        $is_sns_action['DeleteFromCart'][] = $p['productid'];
                }
        }
        $cart = "";
        func_header_location("cart.php");
}

#
# UNSET GIFT CERTIFICATE
#
if ($mode == "unset_gc" && $gcid) {

    foreach ($cart["applied_giftcerts"] as $k=>$v) {
        if ($v["giftcert_id"] == $gcid) {
            $cart["total_cost"] = $cart["total_cost"] - $v["giftcert_cost"];
            continue;
        }
        $tmp[] = $v;
    }
    $cart["applied_giftcerts"] = @$tmp;

    db_query("UPDATE $sql_tbl[giftcerts] SET status='A' WHERE gcid='$gcid'");
    func_header_location("cart.php?mode=checkout");

}

#
# Register member if not registerred yet
# (not a newbie - do not show help messages)
#
$smarty->assign("register_script_name",(($config["General"]["use_https_login"]=="Y")?$xcart_catalogs_secure['customer']."/":"")."cart.php");

if ($mode == "checkout") {
        $usertype = "C";
        $old_action = $action;
        $action = "cart";
        $smarty->assign("action", $action);
        if (empty($login))
                include $xcart_dir."/include/register.php";
        if (!empty($auto_login)) {
            func_header_location("cart.php?mode=checkout&registered=");
        }
        $saved_userinfo = $userinfo;
        $action = $old_action;
}

if (!empty($login)) $userinfo = func_userinfo($login, $current_area, true);
if (!empty($extended_userinfo))
        $userinfo = func_array_merge($userinfo, $extended_userinfo);

#
# Add to cart
#
if($mode=="add" && $productid!="") {

        $added_product = func_select_product($productid, (!empty($user_account['membership'])?$user_account['membership']:""), false, true);

        if ($added_product["forsale"] == "B") {
                $top_message["content"] = func_get_langvar_by_name("txt_pconf_product_is_bundled");
                $top_message["type"] = "W";
                func_header_location($HTTP_REFERER);
        }

        if(!empty($active_modules['Egoods']) && !empty($added_product['distribution'])) {
                $amount = 1;
        }
       
        $amount = abs(intval($amount));

#
# Do addition to cart with options
#
        if($active_modules["Product_Options"]) {
                if (!empty($product_options)) {
                        if(!func_check_product_options ($productid, $product_options)) {
                        if (!empty($active_modules["Product_Configurator"]) and $added_product["product_type"] == "C")
                                  func_header_location("pconf.php?productid=$productid&err=options");
                              else
                            func_header_location("product.php?productid=$productid&err=options");
                        }
                } else {
                        $product_options = func_get_default_options($productid, $amount, @$user_account['membership']);
                        if($product_options === false) {
                                func_header_location ("error_message.php?access_denied&id=30");
                        } elseif($product_options === true) {
                                $product_options = "";
                                unset($product_options);
                        }
                }

                $variantid = func_get_variantid($product_options);
                if(!empty($cart['products']) && !empty($variantid)) {
                        $added_product["avail"] = func_get_options_amount($product_options, $productid);
                        foreach($cart['products'] as $k => $v) {
                                if($v['productid'] == $productid) {
                                        if($variantid == func_get_variantid($v['options'])) {
                                                $added_product["avail"] -= $v['amount'];
                                        }
                                }
                        }
                }
        }

#
# Add to cart amount of items that is not much than in stock
#
        if ($config["General"]["unlimited_products"]=="N" && $added_product["product_type"]!="C")
                if ($amount > $added_product["avail"])
                        $amount = $added_product["avail"];
       
        if ($productid && $amount) {

                if ($amount < $added_product["min_amount"]) {
                        func_header_location ("error_message.php?access_denied&id=31");
                }

                $found = false;
                $product_distribution = func_query_first_cell("SELECT distribution FROM $sql_tbl[products] WHERE productid='$productid'");
                if (!empty($cart) and @$cart["products"] and $added_product["product_type"]!="C") {
                        foreach ($cart["products"] as $k=>$v) {
                                if (($v["productid"] == $productid) && (!$found) && ($v["options"] == $product_options) && empty($v["hidden"])) {
                                        if ((float)$v["free_price"] != $price)
                                                continue;
                                        $found = true;
                                        if (($cart["products"][$k]["amount"] >=1) && !empty($product_distribution))        {
                                                $cart["products"][$k]["amount"]=1;
                                                $amount=0;
                                        }
                                        $cart["products"][$k]["amount"] += $amount;
                                }
                        }
                }
               
                if (!$found) {
                #
                # Add product to the cart
                #
                        if (!empty($price))
                        # price value is defined by customer if admin set it to '0.00'
                                $free_price = abs(doubleval($price));

                        $cartid = func_generate_cartid($cart["products"]);
                        if(empty($cart["products"]))
                                $add_to_cart_time = time();
                        $cart["products"][]=array("cartid"=>$cartid, "productid"=>$productid,"amount"=>$amount, "options"=>$product_options, "free_price"=>@price_format(@$free_price),"distribution"=>$product_distribution);

                        if(!empty($active_modules["Product_Configurator"]))
                                include $xcart_dir."/modules/Product_Configurator/pconf_customer_cart.php";
                }

               
                $intershipper_recalc = "Y";

        } elseif($from == 'partner' && $productid) {
                func_header_location($xcart_catalogs['customer']."/product.php?productid=".$productid);
        }
}

#
# DELETE PRODUCT FROM THE CART
#
if ($mode=="delete" && $productindex!="") {
#
# Delete product from cart
#
        if(!empty($active_modules["Product_Configurator"]))
                include $xcart_dir."/modules/Product_Configurator/pconf_customer_cart.php";

        foreach ($cart["products"] as $k=>$v)
                if ($v["cartid"] == $productindex) {
                        $productid = $v["productid"];
                        if(!empty($active_modules["Advanced_Statistics"]))
                            @include $xcart_dir."/modules/Advanced_Statistics/prod_del.php";
                        array_splice($cart["products"],$k,1);
                        break;
                }
        if (!empty($active_modules['SnS_connector']) && !empty($productid)) {
                $is_sns_action['DeleteFromCart'][] = $productid;
        }
        if (func_is_cart_empty($cart)) {
                $cart = "";
        }
        $intershipper_recalc = "Y";
        func_header_location("cart.php");
}
elseif (!empty($shippingid)) {
        $cart["shippingid"]=$shippingid;
}

if (empty($action)) $action = "";

#
# UPDATES PRODUCTS QUANTITY IN THE CART
#
if ($action=="update") {
        if(!empty($productindexes)) {
#
# Update quantity
#
        foreach($productindexes as $_cartid=>$new_quantity) {
                foreach ($cart["products"] as $k=>$v)
                        if ($v["cartid"] == $_cartid) {
                                $productindexes_tmp[$k] = $new_quantity;
                                break;
                        }
        }
        $productindexes = $productindexes_tmp;
        unset($productindexes_tmp);

        if(!empty($active_modules["Product_Configurator"]))
                include $xcart_dir."/modules/Product_Configurator/pconf_customer_cart.php";

        foreach($cart["products"] as $k=>$v) {
                $tot = 0;
                $tot_amount = 0;
                if($active_modules['Product_Options'] && !empty($v['options']))
                        $vid = func_get_variantid($v['options']);
                foreach($productindexes as $productindex=>$new_quantity) {
                        if (!is_numeric($new_quantity)) continue;
                        if($active_modules['Product_Options'] && !empty($cart["products"][$productindex]['options']))
                                $lvid = func_get_variantid($cart["products"][$productindex]['options']);
                        if ($cart["products"][$productindex]["productid"] == $v["productid"] && $vid == $lvid)
                                $tot += floor($new_quantity);
                }
                foreach($cart["products"] as $k2 => $v2) {
                        if($active_modules['Product_Options'] && !empty($cart["products"][$k2]['options']))
                                $lvid = func_get_variantid($cart["products"][$k2]['options']);
                        if ($v["productid"] == $v2["productid"] && $vid == $lvid)
                                $tot_amount += $v2['amount'];
                }
                $updates_array[$k] = array("quantity"=>$v["amount"], "total_quantity"=>$tot, "total_amount" => $tot_amount);
        }

# Create hash array with variants
        $hash = array();
        if(!empty($active_modules['Product_Options'])) {
                foreach($productindexes as $productindex => $new_quantity) {
                        if(!empty($cart["products"][$productindex]['options'])) {
                                $variantid = func_get_variantid($cart["products"][$productindex]['options']);
                                if($variantid) {
                                        if(!isset($hash[$variantid])) {
                                                $hash[$variantid]['avail'] = func_get_options_amount($cart["products"][$productindex]['options'], $cart["products"][$productindex]['productid']);
                                        }
                                        $hash[$variantid]['old'] += $cart["products"][$productindex]['amount'];
                                        $hash[$variantid]['new'] += $new_quantity;
                                        $hash[$variantid]['ids'][] = $cart["products"][$productindex]['productid'];
                                        $cart["products"][$productindex]['variantid'] = $variantid;
                                }
                        }
                }
        }

# Check&set new quantity
        foreach($productindexes as $productindex => $new_quantity) {
       
                if (!is_numeric($new_quantity) || empty($cart["products"][$productindex]))
                        continue;
               
                $new_quantity = floor($new_quantity);
                $productid=$cart["products"][$productindex]["productid"];
                $total_quantity = $updates_array[$productindex]["total_quantity"];
                $total_amount = $updates_array[$productindex]["total_amount"];
                if ($config["General"]["unlimited_products"]=="N" && $cart["products"][$productindex]["product_type"] != "C")
                        if(!empty($cart["products"][$productindex]['variantid'])) {
                                $amount_max = $hash[$cart["products"][$productindex]['variantid']]['avail'];
                                $total_quantity = $hash[$cart["products"][$productindex]['variantid']]['old'];
                        } else {
                                $amount_max=func_query_first_cell("select avail from $sql_tbl[products] where productid='$productid'");
                        }
                else
                        $amount_max=$total_quantity+1;
                $amount_min=func_query_first_cell("select min_amount from $sql_tbl[products] where productid='$productid'");

                #
                # Do not change
                #
                if ($config["General"]["unlimited_products"] == "Y") {
                        $cart["products"][$productindex]["amount"] = $new_quantity;
                        continue;
                }

                if (($new_quantity >= $amount_min ) && ($products[$productindex]["distribution"]))
                        $cart["products"][$productindex]["amount"] = 1;       
                elseif (($new_quantity >= $amount_min) && ($new_quantity <= ($amount_max-$total_amount+$cart["products"][$productindex]["amount"]))) {
                        $cart["products"][$productindex]["amount"] = $new_quantity;
                        if(!empty($cart["products"][$productindex]['variantid'])) {
                                $hash[$cart["products"][$productindex]['variantid']]['old'] += ($new_quantity-$cart["products"][$productindex]["amount"]);
                        } else {
                                $updates_array[$productindex]["total_amount"] += ($new_quantity-$cart["products"][$productindex]["amount"]);
                        }
                } elseif  ($new_quantity >= $amount_min) {
                        $old_amount = $cart["products"][$productindex]["amount"];
                        $cart["products"][$productindex]["amount"] = ($amount_max-$total_amount+$cart["products"][$productindex]["amount"]);
                        if(!empty($cart["products"][$productindex]['variantid'])) {
                                $hash[$cart["products"][$productindex]['variantid']]['old'] += ($amount_max-$total_amount+$cart["products"][$productindex]["amount"]-$old_amount);
                        } else {
                                $updates_array[$productindex]["total_amount"] += ($amount_max-$total_amount+$cart["products"][$productindex]["amount"]-$old_amount);
                        }
                } else
                        $cart["products"][$productindex]["amount"] = 0;
                if($cart["products"][$productindex]["amount"] < 0)
                        $cart["products"][$productindex]["amount"] = 0;
        }
       
        if(!empty($active_modules["Product_Configurator"])) {
                $pconf_update = "post_update";
                include $xcart_dir."/modules/Product_Configurator/pconf_customer_cart.php";
        }

    foreach($cart["products"] as $index => $product) {
            if($product["amount"] > 0) {
                        $products[] = $product;
                }
                $cart["products"] = $products;
        }
        $intershipper_recalc = "Y";
        }
#
# Update shipping method
#
        if ($config["Shipping"]["realtime_shipping"] == "Y" and !empty($active_modules["UPS_OnLine_Tools"]) and $config["Shipping"]["use_intershipper"] != "Y")
                $current_carrier = $selected_carrier;
       
        if($shippingid!="") $cart["shippingid"]=$shippingid;

        $airborne_account = $arb_account;
        if(!empty($active_modules['SnS_connector']) && !empty($productindexes))
                func_generate_sns_action("CartChanged");
       
        func_header_location("cart.php".(!empty($mode) ? "?mode=$mode" : ""));
}


if (!func_is_cart_empty($cart)) {

        $products = func_products_in_cart($cart, (!empty($userinfo["membership"])?$userinfo["membership"]:""));
    if (is_array($products))
    if (!empty($cart["products"]) and count($products) != count($cart["products"])) {
        foreach($products as $k=>$v) {
            $prodids[] = $v["productid"];
                        $prodids_opts[] = $v['options'];
                }
        if (is_array($prodids)) {
            foreach($cart["products"] as $k=>$v)
                if (in_array($v["productid"], $prodids) && in_array($v["options"], $prodids_opts))
                    $cart_prods[$k] = $v;
                        $cart["products"] = $cart_prods;
        }
                else
                        $cart = "";
                func_header_location("cart.php?$QUERY_STRING");
    }

        if(!empty($active_modules["Subscriptions"])) {
            include $xcart_dir."/modules/Subscriptions/subscription.php";
        }

        if (empty($login) && $config["General"]["apply_default_country"]=="Y") {
                $userinfo["s_country"] = $config["General"]["default_country"];
                $userinfo["s_state"] = $config["General"]["default_state"];
                $userinfo["s_zipcode"] = $config["General"]["default_zipcode"];
                $userinfo["s_city"] = $config["General"]["default_city"];
                $userinfo["s_countryname"] = func_get_country($userinfo["s_country"]);
                $userinfo["s_statename"] = func_get_state($userinfo["s_state"], $userinfo["s_country"]);
        }

#
# Check if only downloadable products placed in cart
#
        $need_shipping = false;
        if ($config["Shipping"]["disable_shipping"]!="Y") {
                if (is_array($products))
                        foreach ($products as $product)
                                if ($product["free_shipping"] == "Y" or ($active_modules["Egoods"] and  $product["distribution"] != "") or ($config["Shipping"]["replace_shipping_with_freight"] == "Y" and $product["shipping_freight"] > 0))
                                        continue;
                                else
                                        $need_shipping = true;
        }

        $smarty->assign("need_shipping", $need_shipping);

        if ($need_shipping) {
        #
        # Get the allowed shipping methods list
        #
                $shipping = func_get_shipping_methods_list($cart, $products, $userinfo);
                $smarty->assign("shipping", $shipping);
                $smarty->assign("current_carrier", $current_carrier);
        }
}

if (!empty($need_shipping)) {
#
# If current shipping is empty set it to default (first in shipping array)
#
        $shipping_matched = false;

        if(!empty($shipping))
                foreach($shipping as $shipping_method)
                        if(@$cart["shippingid"]==$shipping_method["shippingid"]) $shipping_matched=true;

        if(!$shipping_matched && !empty($shipping))
                $cart["shippingid"] = $shipping[0]["shippingid"];

        $cart["delivery"]=func_query_first_cell("select shipping from $sql_tbl[shipping] where shippingid='$cart[shippingid]'");

}
else {
        $cart["delivery"] = "";
        $cart["shippingid"] = 0;
}
               
$smarty->assign("main","cart");

#
# If cart is not empty put products' details into products array
#
if (!func_is_cart_empty($cart)) {
#
# Discount coupons
#
        if($active_modules["Discount_Coupons"])
                include $xcart_dir."/modules/Discount_Coupons/discount_coupons.php";

#
# Calculate all prices
#
        $cart = func_array_merge ($cart, func_calculate($cart, $products, $login, $current_area));

        if (func_is_cart_empty($cart)) {
                $cart = "";
                func_header_location($xcart_web_dir.DIR_CUSTOMER."/error_message.php?product_in_cart_expired");
        } else {
                $products = func_products_in_cart($cart, (!empty($userinfo["membership"])?$userinfo["membership"]:""));
        }

        $smarty->assign("cart",$cart);

}

#
# Redirect
#
if($mode=="add" and $productid) {
        if(!empty($active_modules['SnS_connector'])) {
                func_generate_sns_action("AddToCart", $productid);
        }
        if($config["General"]["redirect_to_cart"]=="Y") {
                func_header_location("cart.php");
        } else{
                if(!empty($HTTP_REFERER)) {
                        func_header_location($HTTP_REFERER);
                } else {
                        func_header_location("home.php?cat=$cat&page=$page");
                }
        }
} elseif (!empty($is_sns_action)) {
        foreach ($is_sns_action as $a => $v) {
                foreach ($v as $v2) {
                        func_generate_sns_action($a, $v2);
                }

        }
        $is_sns_action = array();
}

#
# Wishlist facility
#
if (!empty($active_modules["Wishlist"]) && $mode != "checkout") {
        @include $xcart_dir."/modules/Wishlist/wishlist.php";
}
if ($mode != "wishlist") {
        if ($mode == "checkout")
                $location[] = array(func_get_langvar_by_name("lbl_checkout"), "");
        else
                $location[] = array(func_get_langvar_by_name("lbl_your_shopping_cart"), "");
}

#
# SHOPPING CART FEATURE
#

if (($mode=="checkout") && (!empty($cart["products"])) && (empty($shipping)) && ($login) && $need_shipping && $config["Shipping"]["disable_shipping"]!="Y") {
        func_header_location("error_message.php?error_no_shipping");
}

if ($mode=="checkout" && !func_is_cart_empty($cart) && ($cart["subtotal"]<$config["General"]["minimal_order_amount"]) && $config["General"]["minimal_order_amount"] > 0) {
        func_header_location("error_message.php?error_min_order");
}

if($mode=="checkout" && $login=="" && !func_is_cart_empty($cart)) {
#
# Anonimous checkout
#
        $smarty->assign("main","anonymous_checkout");
        $smarty->assign("anonymous","Y");
        if(empty($userinfo) && !empty($saved_userinfo)) {
                $userinfo = $saved_userinfo;
        }
        $checkout_step = 1;
        $anonymous_checkout = true;

        $location[] = array(func_get_langvar_by_name("lbl_your_order"), "");


} elseif($mode=="checkout" && empty($paymentid) && !func_is_cart_empty($cart) && $cart["total_cost"] == 0) {
        func_header_location($current_location."/payment/payment_offline.php");
} elseif($mode=="checkout" && $paymentid!="" && !func_is_cart_empty($cart)) {
#         
# Check if paymentid isn't faked
#
        $is_egoods = false;
        if($config['Modules']['egoods_manual_cc_processing'] == 'Y') {
                $is_egoods = func_esd_in_cart($cart);
        }
    $membership = $user_account["membership"];
    $is_valid_paymentid = func_query_first_cell("SELECT COUNT(*) FROM $sql_tbl[payment_methods] WHERE paymentid='$paymentid'".(($is_egoods && $paymentid == 1)?"":" AND active='Y'")." AND (membership='' OR  membership='$membership') ");
    if (!$is_valid_paymentid) {
        func_header_location("cart.php?mode=checkout&err=paymentid");
        }

#
# Generate uniq orderid which will identify order session
#
        $order_secureid = md5(uniqid(rand()));
#
# Show payment details checkout page
#
        $payment_cc_data = func_query_first("SELECT * FROM $sql_tbl[ccprocessors] WHERE paymentid='$paymentid'");
        if($is_egoods && $paymentid != 1 && !empty($payment_cc_data)) {
                $paymentid = 1;
                $payment_cc_data = array();
        }
        $smarty->assign("payment_cc_data", $payment_cc_data);
#
# Generate payment script URL depending on HTTP/HTTPS settings
#
        $payment_data = func_query_first("select * from $sql_tbl[payment_methods] where paymentid='$paymentid'");
        $payment_data["payment_script_url"] = ($payment_data["protocol"]=="https"?$https_location:$http_location)."/payment/".$payment_data["payment_script"];

        $smarty->assign("payment_data",$payment_data);
        if(!empty($payment_cc_fields)) {
                $userinfo = func_array_merge($userinfo, $payment_cc_fields);
        }
        $smarty->assign("userinfo",$userinfo);
        $smarty->assign("main","checkout");

        if ($checkout_step_modifier["payment_methods"] == 1)
                $smarty->assign("ignore_payment_method_selection", 1);
       
        $checkout_step = 2 + $checkout_step_modifier["anonymous"] - $checkout_step_modifier["payment_methods"];

        $location[] = array(func_get_langvar_by_name("lbl_payment_details"), "");

} elseif($mode=="checkout" && !func_is_cart_empty($cart)) {
#
# Show checkout page with payment options only methods availiable to current
#  membership level are displayed
#
        $payment_methods = check_payment_methods(@$user_account["membership"]);
        if (count($payment_methods) == 1)
                func_header_location("cart.php?paymentid=".$payment_methods[0]["paymentid"]."&mode=checkout");

        if (!empty($payment_methods))
                $payment_methods[0]["is_default"] = 1;

        $checkout_step = 1 + $checkout_step_modifier["anonymous"] - $checkout_step_modifier["payment_methods"];

        $smarty->assign("payment_methods",$payment_methods);
        $smarty->assign("main","checkout");

        $location[] = array(func_get_langvar_by_name("lbl_payment_details"), "");

}
elseif ($mode=="order_message") {
        $smarty->assign("main","order_message");
        $location[] = array(func_get_langvar_by_name("lbl_order_processed"), "");

}
elseif ($mode=="auth") {
        $smarty->assign("main","checkout");
        $checkout_step = 1;
}

require $xcart_dir."/include/categories.php";

if($active_modules["Manufacturers"])
    include $xcart_dir."/modules/Manufacturers/customer_manufacturers.php";

$giftcerts = (!empty($cart["giftcerts"])? $cart["giftcerts"] : array());

#
# In this mode cart.php show info about existing order (order_message)
#
if (!empty($orderids)) {

        if (empty($login))
                func_header_location("error_message.php?access_denied&id=32");

        $orders = array ();
        $_orderids = split (",",$orderids);

        foreach ($_orderids as $orderid) {
                $order_data = func_order_data($orderid);
                $order_data['products'] = func_translate_products($order_data['products'], $shop_language);
#
# Security check if current customer is not order's owner
#
                if ($order_data["order"]["login"]!=$login) unset($order_data);

                $orders[] = $order_data;
        }

        $smarty->assign("orders", $orders);
        if ($action == "print") {
                $smarty->assign("template", "customer/main/order_message.tpl");
                func_display("customer/preview.tpl",$smarty);
                exit;
        }
        $smarty->assign("orderids", $orderids);
}

include "./minicart.php";

if(!empty($payment_cc_fields)) {
        $userinfo = func_array_merge($userinfo, $payment_cc_fields);
}
if(!empty($login) || $mode != 'checkout') {
        $smarty->assign("userinfo",@$userinfo);
}
$smarty->assign("products",@$products);
$smarty->assign("giftcerts",$giftcerts);

if ($mode == "checkout" || $mode == "auth") {
        $smarty->assign("checkout_step",$checkout_step);
        $smarty->assign("total_checkout_steps",$total_checkout_steps);       
}

if (!empty($order))
        $smarty->assign("order",$order);

if (!empty($login))
    db_query("UPDATE $sql_tbl[customers] SET cart='".addslashes(serialize($cart))."' WHERE login='$login'");
       
if (func_use_arb_account()) {
        $smarty->assign("use_airborne_account", true);
        $smarty->assign("airborne_account", $airborne_account);
}
x_session_save();

# Assign the current location line
$smarty->assign("location", $location);

func_display("customer/home.tpl",$smarty);

?>


Thanks for the help! :)

jeanne 06-07-2005 12:14 PM

90%
91%
92%
93%
94%
95%
960%
961%

is how I have my destination zone that I use for taxes set up. It is not in the code. It's under Inventory-> Destination Zones
I am taxing orders to all Zip Codes in California so when you enter a zip code that matches (% are the wild cards in this set up) the tax shows up.
How do you have your taxing zone set up?
Does it check by zip code, state, city ????

jedak 06-07-2005 09:58 PM

Quote:

Originally Posted by jeanne
90%
91%
92%
93%
94%
95%
960%
961%

I forgot wildcards could be used. :oops:

Quote:

Originally Posted by jeanne
It's under Inventory-> Destination Zones
I am taxing orders to all Zip Codes in California so when you enter a zip code that matches (% are the wild cards in this set up) the tax shows up.
How do you have your taxing zone set up?
Does it check by zip code, state, city ????

Under Inventory-> Destination Zones I have state city and zipcodes entered. Could it be because I have the cities entered??
Thanks

TJ Stephens 06-07-2005 10:09 PM

Jedak,

I think I am having the same problem as you. Try going to "taxing system" under management and uncheck "Display cart/order totals including tax:". See if this makes it display the taxes. I'm using 4.0.13 too and if this box is checked then it displays takes for me with the pre-login shipping calculator. If I uncheck it (which I want to do for formating reasons) then the total still includes the taxes but the tax line displays "n/a" instead of the actual tax amount. Is this the same thing you are having trouble with? If so, I will let you know if I figure out how to fix this and please do the same if you find a fix.

TJ


All times are GMT -8. The time now is 04:17 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.