Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Anono

Archived
  • Posts

    6
  • Joined

  • Last visited

  • Days Won

    1

Anono last won the day on December 25 2009

Anono had the most liked content!

Profile Information

  • Real Name
    Anono

Anono's Achievements

  1. Here is help for the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/html/oscommerce/includes/functions/database.php on line 99 Line 98-100 of my database.php file contained: function tep_db_fetch_array($db_query) { return mysql_fetch_array($db_query, MYSQL_ASSOC); } Clearly, somewhere in my code I had a call to tep_db_fetch_array, in which I was passing an invalid resource. The proper way to call tep_deb_fetch_array is to first prepare a select statement using tep_db_query, as shown below: $my_select_statement = 'Select * from ' . TABLE_CATEGORIES; $my_query = tep_db_query($my_select_statement); while ($my_result_row = tep_db_fetch_array($my_query)) { $my_cat_id = $my_result_row['categories_id']; .... } The function tep_db_query returns an resource of type 'mysql result'. If $my_query had been an invalid resource (eg not defined, or null, containing a string or numeric value, or containing anything at all other than a properly formed 'mysql result' resource), then it would have caused warning message I saw. One way of testing your code is to call mysql_query directly, bypassing all the osc wrappers, like so: $my_select_statement = 'Select * from ' . TABLE_CATEGORIES; $qr1 = mysql_query ($my_select_statement) or die ("Query failed: " . mysql_error() . " Actual query: " . $my_select_statement); In my case, I got this warning message after making a mistake in installing Linda McGrath's very nice addon Attributes Sorter and Copier (http://www.oscommerce.com/community/contributions,772) version 5.1b. It concerned some tricky merging of code in the file catalog\admin\categories.php, tricky because I had already edited that section of code with other addons (Additional Images and New Attribute Manager). I had the line: while ($new_images = tep_db_fetch_array($images_product)) { But $images_product was undefined because I had overwritten the code that defined it. The tricky section of code in file catalog\admin\categories.php started with: default: if ($rows > 0) { if (isset($cInfo) && is_object($cInfo)) { and ended with: } else { // create category/product info $heading[] = array('text' => '<b>' . EMPTY_CATEGORY . '</b>'); $contents[] = array('text' => TEXT_NO_CHILD_CATEGORIES_OR_PRODUCTS); } break; } By reinstalling this section of code from my backup, and then more carefully installing the Attributes Sorter and Copier addon, I was able to fix the problem.
  2. Force Carrier Calculated Shipping for Zero Weight Items We're going to be selling a lot of low-weight items online, and intend to use GoogleCheckout with carrier caluculated shipping. In our case, shipping charges vary little by the quantity we package into a given shipment, and so we'd rather not take the trouble to enter a weight value for each product we offer when we add the product to our online store. However, we found that carrier caluclated shipping doesn't work for a zero-weight package (no big surprise). What the system does is use the 'Default Values' you specify for 'Carrier Calculater Shipping Configuration' - the same values it would use if it had been unable to communicate with the carrier's site. The problem here of course is that it is the same value, regardless of destination. Our solution was to force a mimum weight of 0.01 LBS for all shipment items. The carrier caluclated shipping charges provided by all three carriers (FedEx, UPS and USPS) now work; they round the total shipment weight up to a minimum of 1 LB. in catalog\googlecheckout\library\googleitem.php, near line 76. Change this: $this->item_weight = 'LB'; } $this->numeric_weight = (double)$numeric_weight; } } To this: $this->item_weight = 'LB'; } $this->numeric_weight = (double)$numeric_weight; } // Change to force minimum weight for each item if ($this->numeric_weight==0) {$this->numeric_weight = 0.01;} // End of change to force minimum weight for each item }
  3. Here is how we are setting up our osCommerce store to handle sales tax by zip code using GoogleCheckout v1.4.5_CCS. We have a brick & mortar store in San Mateo county, California and want to start selling online. Our osCommerce store will feature GoogleCheckout only. In other words, online customers will not create a customer account at our site and they will have only one checkout option: GoogleCheckout. Our problem was how to charge sales tax. 1) First, what's the law about sales tax in California for online sellers? There is a state-wide charge of 7.25% you have to collect for all online sales shipped within the state, if you have a physical presence in the state. There are also many 'districts' in California, each with different sales taxes added on to the state-wide rate; you have to collect these additional district sales taxes only for the district where you have a physical presence. Read more about this at the California State Board of Equalization website (www.boe.ca.gov), especially publications 71, 44 and 105. In our case, because we have a physical presence in the district of San Mateo county, we are required to collect: 0% sales tax on shipments outside of California 7.25% sales tax on all shipments to California locations 8.25% sales tax on all shipments within San Mateo county To make things more interesting, you cannot reliably identify shipments to a California sales tax district by zip code. Some zip codes extend across sales tax district lines. But you have to start somewhere. You can get a list of all zip codes for a given county at melissadata.com. We found there are 38 zip codes that lie within San Mateo county, and one zip code (94303) that stretches across San Mateo and Santa Clara counties. What to do with this one zip code that encompasses residents in both San Mateo and Santa Clara counties? It turns out that Santa Clara county has a sales tax rate of 8.75%. We're not legally required to collect Santa Clara county tax, but we're allowed to do so. In theory, Santa Clara county residents shouldn't complain if we collect 8.25% sales tax from them, because they are required to pay the full 8.75% sales tax as a 'use tax' and they can get credit for the 8.25% we will have collected from them. Bottom line: we decided to collect 8.25% for all 39 zip codes in San Mateo county, even the one that extends into Santa Clara county. Melissadata.com tells us that 51% of the addresses in zip code 94303 are in Santa Clara county, and we intend to pay Santa Clara county 51% of 1% of all online sales shipped to zip code 94303. 2) It is easy to configure osCommerce to charge the 7.25% sales tax on all shipments to California. Start in admin. In the menu on the left, click on 'Localizations / Taxes'. 2.1) Click on 'Tax Zones' to display the Tax Zone page. Click 'Insert' to create a new Tax Zone. Name: California. Description: California Sales Tax. 2.2) Then (still on the Tax Zone Page), click on your newly-created Tax Zone for California. Notice on your browser's address box that you are running catalog/admin/geo_zones.php. This is the place to insert geo_zones that will be assigned to your newly-created tax zone of California. Click 'Insert'. First select 'United States' from the country drop-down box. Then select 'California' from the zone drop-down box. Click 'Insert' then 'Back'. (While you're here, you might want to remove the Florida Tax Zone that is pre-configured of osCommerce, out of the box). 2.3) Click on 'Tax Rates' in the menu at left to display the Tax Rates page. Click 'New Tax Rate'. Tax Class Title: taxable goods. Zone: California. Tax Rate: 7.25%. Description: California Sales Tax. Priority: 1. Click 'Insert' to save the record. GoogleCheckout will use this state-wide sales tax rate of 7.25%. 3) Our problem was how to make GoogleCheckout charge sales tax based on zip codes. It should charge 8.25% on shipments to the 39 zip codes in San Mateo county. There are a number of osCommerce addins that apply sales tax to zip codes, but most appear to require the creation of a customer account at your osCommerce site, and our intention is to create a site without customer accounts. In other words, the customer at our online site would be able to use GoogleCheckout to pay for a purchase without having to create an account at our site. Our solution is a cludge, and rather ugly because we're hard-coding the 39 zip codes into our php code, but it does work and we'll use it until we develop something better. In file catalog/googlecheckout/gcheckout.php, near line 673, find the following lines: $num_rows = tep_db_num_rows($tax_rates_result); $tax_rule = array (); $GAtaxTable = new GoogleAlternateTaxTable((!empty($tax_name_array[$i])?$tax_name_array[$i]:'none'), 'false'); Directly below this, insert the following code: //** Start of Zip Code Based Tax Rules ************* // $zipRate = ".0825"; // Sales tax rate for San Mateo county $newGAtaxRule = new GoogleAlternateTaxRule($zipRate); $zipsArray = array(); $zipsArray[] = "94002"; // Belmont $zipsArray[] = "94005"; // Brisbane $zipsArray[] = "94010"; // Burlingame // ...etc. Add all 39 zip codes for San Mateo county to $zipsArray $newGAtaxRule->SetZipPatterns($zipsArray); $GAtaxTable->AddAlternateTaxRules($newGAtaxRule); // //** End of Zip Code Based Tax Rules ************* 4) Testing the Code. You should already have GoogleCheckout installed and configured to use your sandbox account. The GoogleCheckout button should display on your shopping cart page. All the code specifying sales tax is executed whenever the user displays this page. Add something to your cart and then view the source for the shopping cart page. Find the code that reads: <input type="hidden" name="cart" value=" The value is a long, long string of alphanumerics enclosed within double quotes. It is the XML sent by your site to the GoogleCheckout site, encoded to base64. Copy everything within the double quotes to your clipboard and then paste it into a base64 decoder. I've been using http://demo.globant.com/~brovagnati/tools/base64decode.php. (Thanks to the people who developed and posted that!) Press 'Decode' to see the XML. It should display your sales tax rules, something like what you see below: ... <alternate-tax-tables> <alternate-tax-table standalone="false" name="Taxable Goods"> <alternate-tax-rules> <alternate-tax-rule> <rate>.0825</rate> <tax-area> <us-zip-area> <zip-pattern>94002</zip-pattern> </us-zip-area> </tax-area> </alternate-tax-rule> <alternate-tax-rule> <rate>.0825</rate> <tax-area> <us-zip-area> <zip-pattern>94005</zip-pattern> </us-zip-area> </tax-area> ... <alternate-tax-rule> <rate>0.0725</rate> <tax-area> <us-state-area> <state>CA</state> </us-state-area> </tax-area> </alternate-tax-rule> ... Notice that the zip-code rules are specified BEFORE the CA state rules. GoogleCheckout API requires the most specific rules first. Read more about the GoogleCheckout API for tax rules here: http://code.google.com/apis/checkout/devel..._API_Taxes.html 5) Testing the Code in the Sandbox. After you create your Googlecheckout sandbox buyer account, you can test the code in the sandbox. The trick here is that on the first GoogleCheckout page, called up after you enter your GoogleCheckout buyer account login and password, you can specify alternative 'Ship to' locations and even add new 'Ship to' locations on the fly. Test your zip-code based sales tax rules by creating new 'Ship to' locations and watch the tax charged on that page change as you change locations. Hope this helps. I'd like to hear about it if anyone has any comments or suggestions. Anono
  4. Many thanks for the contribution. I installed the 11 Jan 2008 version (2.04.2) and it works fine. It even works and plays nicely with STS. I did encounter one minor problem when adding child information topics. Links to the children topics would appear just as expected in the Info Box, but whenever I clicked on the link to the first child then the links to all child topics for that parent would dissapear. Although the topic information content would appear as expected, the child links would collapse and show only the parent link. This problem occured only for the first child; a click on the links for subsequent children worked just fine. I'm not an expert at php, but I think I may have found a solution. In the file catalog\includes\functions\information.php, near line 47: Find: // Test if a child has been requested and set $parent_child_selected for ( $i = 1; $i < ($count_child+1); $i++ ) { Replace with: // Test if a child has been requested and set $parent_child_selected for ( $i = 0; $i < ($count_child); $i++ ) { This seemed to correct the problem for me. A great contribution! Many thanks for all the work Joeri, Luca and others have put into it.
×
×
  • Create New...