tahuti Posted March 14, 2004 Share Posted March 14, 2004 Any help would be greatly appreciated.....and I surely apologize for the cry for help but I am at a loss and have wasted countless hours trying this or that only to no avail...... This may be a long post by the time I'm done so sorry for that too.... The short story is this..... I'm trying to pull the info from a field called products_ship_zipcode which I added into my PRODUCTS TABLE and place that information into a variable called $zipcode.... I seem to be able to do this by including the db call into the following code.... $product_query = tep_db_query("select products_id, products_price, products_ship_price, products_ship_price_two, products_ship_zipcode, products_ship_method, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . tep_get_prid($products_id) . "'"); if ($product = tep_db_fetch_array($product_query)) { $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $products_weight = $product['products_weight']; // EMVS $products_ship_price = $product['products_ship_price']; $products_ship_price_two = $product['products_ship_price_two']; $zipcode = $product['products_ship_zipcode']; And I believe that the above works..... But down the pipeline later it seems that other functions can not see the $zipcode variable or that the $zipcode variable is void...... Since I know you need more info to solve this problem..... Here is the long story..... If you want to see the full version of what I'm talking about please see http://www.oscommerce.com/community/contributions,1928 which is the contribution I'm trying to get working.....Everything works great except my zipcode call......If someone is willing to download my contribution and check this all out and present a solution I would gladly credit them in my documentation with any tagline you might desire...... But to explain more here..... I have tried to put this into the shopping_cart.php file in the calculate function: function calculate() { global $zipcode; $this->total = 0; $this->weight = 0; // EMVS $this->shiptotal = 0; // Get shipping methods $methods = tep_db_fetch_array(tep_db_query("select method_name from " . TABLE_SHIPPING_METHODS)); $mltcount = sizeof($methods); $this->multi_weight = NULL; for($i = 0; $i < $mltcount; $i++){ $this->multi_weight[] = Array($methods[$i]=>0); } // End EMVS if (!is_array($this->contents)) return 0; reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; // products price $product_query = tep_db_query("select products_id, products_price, products_ship_price, products_ship_price_two, products_ship_zipcode, products_ship_method, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . tep_get_prid($products_id) . "'"); if ($product = tep_db_fetch_array($product_query)) { $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $products_weight = $product['products_weight']; // EMVS $products_ship_price = $product['products_ship_price']; $products_ship_price_two = $product['products_ship_price_two']; $zipcode = $product['products_ship_zipcode']; $ship_method = $product['products_ship_method']; $this->multi_weight[$ship_method] += ($qty * $products_weight); // End EMVS You can see I used a global which I thought I needed to use.... And then I'm trying to let my ups.php file in the shipping modules directory acces this information in the quote function: function quote($method = '') { global $HTTP_POST_VARS, $order, $shipping_weight, $shipping_num_boxes, $zipcode; if ( (tep_not_null($method)) && (isset($this->types[$method])) ) { $prod = $method; } else if ($order->delivery['country']['iso_code_2'] == 'CA') { $prod = 'STD'; } else { $prod = 'GNDRES'; } if ($method) $this->_upsAction('3'); // return a single quote $this->_upsProduct($prod); // $vendor_query = tep_db_query("select vendors_zipcode from " . TABLE_VENDORS . " where vendors_id = '" . (int)$vendor_id . "'"); //$vendor = tep_db_fetch_array($vendor_query); //$vendor = tep_get_zip($products_id); //$ship_zipcode_query = tep_db_query("select products_ship_zipcode from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and products_id = products_id"); //$ship_zipcode = tep_db_fetch_array($ship_zipcode_query); //$zipcode = $ship_zipcode['products_ship_zipcode']; $country_name = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true); $this->_upsOrigin($zipcode, $country_name['countries_iso_code_2']); $this->_upsDest($order->delivery['postcode'], $order->delivery['country']['iso_code_2']); $this->_upsRate(MODULE_SHIPPING_UPS_PICKUP); $this->_upsContainer(MODULE_SHIPPING_UPS_PACKAGE); $this->_upsWeight($shipping_weight); $this->_upsRescom(MODULE_SHIPPING_UPS_RES); $upsQuote = $this->_upsGetQuote(); This also shows some //comented out code I had tried to no avail.... Again I used the global $zipcode...but nothing seems to work..... I also tried setting up a tep_get_zipcode function in the general.php file in the functions directory but could not get this to work either..... I need help....Please........ To get a better idea of all my inner workings please do check out my beta release of my EMVS contribution here: http://www.oscommerce.com/community/contributions,1928 Thanks for any time and effort spent on this issue...I think that my contribution will be a much used and appreciated one for all osc users.... Link to comment Share on other sites More sharing options...
♥yesudo Posted March 15, 2004 Share Posted March 15, 2004 one thought occured - is there a default value you have used for the new field for existing products or is the table empty and it is not working with the first(and only) product you try ? Your online success is Paramount. Link to comment Share on other sites More sharing options...
tahuti Posted March 15, 2004 Author Share Posted March 15, 2004 The existing products new fields are initially empty...no default....until a zipcode is assigned and I have only tried this with products in the basket which have been assigned zipcodes already.... I think the issue might be more like this...... I wonder if the order of the functions calls is the otherway around and that the function in which I'm setting the variable is called after the one where I try to use it? I had had success calling the variable $zipcode from the db when querying from the mltship.php file and using it in the ups.php file...but only when the ship_zipcode field was part of the shipping_methods table.... I now have the ship_zipcode field...now named products_ship_zipcode...in the products table itself and would like to call it from there.... So this is the code I was trying to use in the mltship.php file: $result = tep_db_query("select s.method_name, s.module_name, s.handling_charge, s.handling_per_box, s.tare_weight, s.max_box_weight, p.products_id, p.products_ship_zipcode from " . TABLE_SHIPPING_METHODS . " s, " . TABLE_PRODUCTS . " p where p.products_id='" . tep_get_prid($products_id) . "'"); And then assigning it as below: while($row = tep_db_fetch_array($result)) { /*Change the shipping wieght to the wieght for this method*/ $shipping_weight = $ms_weight[$row['method_name']]; if($shipping_weight > 0) { //Setup the varibles needed $mlt_num_boxes = ceil($shipping_weight/$row['max_box_weight']); $shipping_weight /= $mlt_num_boxes; $shipping_weight += $row['tare_weight']; $zipcode = $row['products_ship_zipcode']; But it didn't seem to work.... I also tried: $result = tep_db_query("select s.method_name, s.module_name, s.handling_charge, s.handling_per_box, s.tare_weight, s.max_box_weight, p.products_id, p.products_ship_zipcode from " . TABLE_SHIPPING_METHODS . " s, " . TABLE_PRODUCTS . " p where p.products_id='" . $products_id . "'"); Which changed the last part of the call but it did not work either...... I also tried changing the code for the assignment of the variable to: $zipcode = $row['p.products_ship_zipcode']; But it didn't seem to work either... The code below did work but only when the zipcode field was in the shipping_methods table: $result = tep_db_query("select method_name, module_name, handling_charge, handling_per_box, tare_weight, max_box_weight, zipcode from " . shipping_methods); $mltcount = sizeof($methods); $ms_weight = $cart->get_multi_weight(); while($row = tep_db_fetch_array($result)) { /*Change the shipping wieght to the wieght for this method*/ $shipping_weight = $ms_weight[$row['method_name']]; if($shipping_weight > 0) { //Setup the varibles needed $mlt_num_boxes = ceil($shipping_weight/$row['max_box_weight']); $shipping_weight /= $mlt_num_boxes; $shipping_weight += $row['tare_weight']; $zipcode = $row['zipcode']; Any one out there know the proper way to call the zipcode information from the field when it is attached to the product itself in the products table? And can this type of call be attached to the product and be used from this point in the file flow since it needs to be looped through for each product in the shopping cart or do I need to call it from the shopping_cart.php file once I have it attached to the products table?? Those I guess are my two real questions..... Thanks for any help..... Link to comment Share on other sites More sharing options...
tahuti Posted March 16, 2004 Author Share Posted March 16, 2004 If anyone is looking for a challenge please feel free to check out my issues here....I would love some input......Thanks for any help anyone can provide...... Link to comment Share on other sites More sharing options...
tahuti Posted March 19, 2004 Author Share Posted March 19, 2004 Anyone care to help out on this project? Please see contribution: http://www.oscommerce.com/community/contributions,1928 Please?..................? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.