PHP - Code To Use To Capture Shipping Info
Hi there,
I am trying to edit my shopping cart page so that i can use a different shipping rate for each country that i ship to. At the minute this is the code i use: */ if(isset($_GET['eushipping'])||(isset($_POST['rec_country'])&&$_POST['rec_country']!='uk')){ $shipping = ceil($total/30.00)*20.00; } I though it if i just changed the value 'eushipping' to the country option value it would work but it doesn't. Can anyone point me in the write direction of what i need to change? Many thanks. Hash Similar TutorialsHi Can anyone tell me why this code is not displaying anything besides book: Im new to OOP in php and need some help getting the following to run properly Code: [Select] <?php class ShopProduct{ public $title = "Where eagles dare"; public $producerMainName = "McLean"; public $producerFirstName = "Alistair"; public $price = 179; function getProducer(){ return "{$this->producerFirstName}"; "{$this->producerMainName}"; } } $product1 = new ShopProduct(); $product1->title=""; $product1->producerMainName=""; $product1->producerFirstName=""; $product1->price=""; print "Book: {$product1->getProducer()}\n"; ?> I need a little help here. I have a function currently that allows me to send data to a php script from my C++ application. How can I do the opposite? C++ Code below to send data to the php script: Code: [Select] void SendData() { char* Navigate = new char[500]; memset(( void* )Navigate, 0, 500); char* Version = "Version 1.0"; sprintf(Navigate, "MYSITE.COM/GetData.php?v=%s", Version); SendFunction(Navigate); } DWORD SendFunction(char* link) { char* szURL = link; HINTERNET hSession; HINTERNET hRequest; hSession = InternetOpen( // Make internet connection. "Microsoft Internet Explorer", // agent INTERNET_OPEN_TYPE_PRECONFIG, // access NULL, NULL, 0); // defaults if(hSession) { hRequest = InternetOpenUrl( // Make connection to desired page. hSession, // session handle link, // URL to access NULL, 0, 0, 0); // defaults } if(hRequest) { bool bResult = HttpSendRequest(hRequest, NULL, 0, NULL, 0); } InternetCloseHandle(hSession); return 0; } php script that receives the data from the C++ application: <? $f=fopen('FILE','a'); fwrite($f,$_GET['v'] \n); fclose($f); ?> This just simply sends the char* Version = "Version 1.0" text to the php script witch _GETs it and writes it to a file. Simple and impractical, however I just wanted to get something rolling. It works fine, now I need to do the opposite. I need to do exactly what this function does, but flip it around!. I want store a value in the php script, and get that value with my C++ application, and then log it out. Any help here please!? php script for what I want to do: <?php $dbhost = 'MyHost'; $dbuser = 'MyUserName'; $dbpass = 'MyPassword'; mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'MyDB'; mysql_select_db($dbname); $query = mysql_query("SELECT * FROM AppVersion"); while($row = mysql_fetch_array($query)) { $version = $row['Version Info']; } ?> I need to query the php script from my C++ application and retrieve the value of $version. How can I setup the php script to export that value $version for the C++ app and use the WinInet funcs to retrieve it? Note: I am just trying to get a feel for how all of this works right now, so none of this really has a practical use at the moment, but is helping me progress in my overall goal, so it will be very helpful to get this worked out. Hello every one i need your help please about this i would like to add this tabs to my facebook fan page i got App allowing me to put php coding or html but i need when some one add his info and click on submit i receive it at my email so can any 1 here help me or tell me what shall i do ? i newbie and hope to get your help guys please Hey everyone, Just want to say please move this thread if this is the wrong place. I have made a shopping cart for a client from scratch, and now the ONLY thing stopping me from finishing it is a SHIPPING calculator. ALL the stupid API's from these companies like UPS make absolutely no sense, half of them required PHP extensions to be installed, and I got many errors with that departement too... Now how does osCommerce or Ebay do this? Is there anywhere out there where there is a tutorial on completing this task? I have a list of id's between 1 - 8 which represents a print size that I need to use to calculate shipping costs, but the calculation that I need to perform is complicated. I will try to explain to the best of my abilities. I also need to query a database table to make sure the shipping rates are always up-to-date id's <= 4 will ship for $4.95 now matter how many id's are listed. Eg: 1,2,3,4,3,2,4,2,4 will ship for a total of $4.95 will query price db as 1 id's <= 5 will ship for $6.00 now mater how many id's are listed. Eg: 1,3,3,1,2,3,5,5,5,4,3,3 will ship for a total of $6 will query price db as 2 id's <= 6 will ship for $8.00 now mater how many id's are listed. Eg: 1,3,6,1,6,3,5,5,5,4,3,3 will ship for a total of $8.00 will query price db as 3 id 7 will ship for $5 * Quanity + any of the examples above will query price db as 4 id 8 will ship for $15 * Quantity + any of the examples above will query price db as 5 table structure for shiprates is id, price the PHP below counts the number of items but not the total quantity (quantity_1) to calculate the value of $shipping. any ideas? link to form: http://crsecrets.com/test01/order.html FORM Code: [Select] <TD>Herbal Hair Rejuvenator, Unscented <FONT SIZE="-2">(4oz. jar)</FONT><input type="hidden" name="item_name_1" value="Herbal Hair Rejuvenator, Unscented (4oz. jar)" /> </TD> <TD align="center" id="table"><input name="quantity_1" type="text" value="" size="6" maxlength="2" /></TD> <TD align="center">$13.50<input type="hidden" name="amount_1" value="13.50" /></TD> Code: [Select] [m]<?php $products = array(); $url = "?business=*********$handling_cart=7.00"; foreach ($_POST as $k=>$v) { preg_match("/\_(\d{1,3})$/",$k,$match); $key = $match[1]; $products[$key][$k] = $v; } $i=1; foreach ($products as $k=>$v) { if ($v['quantity_'.$k] > 0) { foreach ($v as $k1=>$v1) { $key = explode("_",$k1); switch($key[0]) { case 'item': $var = "item_name_" . $i; break; case 'quantity': $var = "quantity_" . $i; break; case 'amount': $var = "amount_" . $i; break; } //get shipping for additional items above 3 if ($i <= 2) { $shipping = "0.00"; } else { $shipping = "1.00"; } $shipping = ($shipping * $v['quantity_' . $k]); $url .= "&" . $var . "=" . urlencode($v1); } $url .= "&shipping_" . $i . "=" . $shipping; $i++; } } #echo $url; header("Location: https://www.paypal.com/cgi-bin/webscr" . $url); exit; ?>[/m] This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=345769.0 Hi there, I would like to customize $shippingCost in my shopping cart. I follow a tutorial from: http://www.phpwebcommerce.com/plaincart/index.php This tutorial using flat shipping rate, how to customize shippingCost based on the product weight ? Example: shipping method will based on weight & place within Malaysia: west malaysia, up to 1kg = rm9 east malaysia, up to 1kg = rm12 west malaysia, up to 2kg = rm12 east malaysia, up to 2kg = rm16 west malaysia, up to 5kg = rm18 east malaysia, up to 5kg = rm32 west malaysia, up to 10kg = rm24 east malaysia, up to 10kg = rm48 Do i need to create a new field inside my database for product weight ? is it $weight * $product_quantity ? Does anyone know how to accomplish this customization? . Please help because I am very confuse. Thank you in advanced checkout-functions.php: Code: [Select] <?php require_once 'config.php'; /********************************************************* * CHECKOUT FUNCTIONS *********************************************************/ function saveOrder() { $orderId = 0; $shippingCost = 5; $requiredField = array('hidShippingFirstName', 'hidShippingLastName', 'hidShippingAddress1', 'hidShippingCity', 'hidShippingPostalCode', 'hidPaymentFirstName', 'hidPaymentLastName', 'hidPaymentAddress1', 'hidPaymentCity', 'hidPaymentPostalCode'); if (checkRequiredPost($requiredField)) { extract($_POST); // make sure the first character in the // customer and city name are properly upper cased $hidShippingFirstName = ucwords($hidShippingFirstName); $hidShippingLastName = ucwords($hidShippingLastName); $hidPaymentFirstName = ucwords($hidPaymentFirstName); $hidPaymentLastName = ucwords($hidPaymentLastName); $hidShippingCity = ucwords($hidShippingCity); $hidPaymentCity = ucwords($hidPaymentCity); $cartContent = getCartContent(); $numItem = count($cartContent); // save order & get order id $sql = "INSERT INTO tbl_order(od_date, od_last_update, od_shipping_first_name, od_shipping_last_name, od_shipping_address1, od_shipping_address2, od_shipping_phone, od_shipping_state, od_shipping_city, od_shipping_postal_code, od_shipping_cost, od_payment_first_name, od_payment_last_name, od_payment_address1, od_payment_address2, od_payment_phone, od_payment_state, od_payment_city, od_payment_postal_code) VALUES (NOW(), NOW(), '$hidShippingFirstName', '$hidShippingLastName', '$hidShippingAddress1', '$hidShippingAddress2', '$hidShippingPhone', '$hidShippingState', '$hidShippingCity', '$hidShippingPostalCode', '$shippingCost', '$hidPaymentFirstName', '$hidPaymentLastName', '$hidPaymentAddress1', '$hidPaymentAddress2', '$hidPaymentPhone', '$hidPaymentState', '$hidPaymentCity', '$hidPaymentPostalCode')"; $result = dbQuery($sql); // get the order id $orderId = dbInsertId(); if ($orderId) { // save order items for ($i = 0; $i < $numItem; $i++) { $sql = "INSERT INTO tbl_order_item(od_id, pd_id, od_qty) VALUES ($orderId, {$cartContent[$i]['pd_id']}, {$cartContent[$i]['ct_qty']})"; $result = dbQuery($sql); } // update product stock for ($i = 0; $i < $numItem; $i++) { $sql = "UPDATE tbl_product SET pd_qty = pd_qty - {$cartContent[$i]['ct_qty']} WHERE pd_id = {$cartContent[$i]['pd_id']}"; $result = dbQuery($sql); } // then remove the ordered items from cart for ($i = 0; $i < $numItem; $i++) { $sql = "DELETE FROM tbl_cart WHERE ct_id = {$cartContent[$i]['ct_id']}"; $result = dbQuery($sql); } } } return $orderId; } /* Get order total amount ( total purchase + shipping cost ) */ function getOrderAmount($orderId) { $orderAmount = 0; $sql = "SELECT SUM(pd_price * od_qty) FROM tbl_order_item oi, tbl_product p WHERE oi.pd_id = p.pd_id and oi.od_id = $orderId UNION SELECT od_shipping_cost FROM tbl_order WHERE od_id = $orderId"; $result = dbQuery($sql); if (dbNumRows($result) == 2) { $row = dbFetchRow($result); $totalPurchase = $row[0]; $row = dbFetchRow($result); $shippingCost = $row[0]; $orderAmount = $totalPurchase + $shippingCost; } return $orderAmount; } ?> any help will be greatly appreciated Hey guys,
I need some help with a simple script a friend wrote for me but isn't returning the correct values. I'm looking to get this script working but my PHP skills are abysmal and I can't for the life of me figure out whats the best way to do this. I've tried contacting my friend but he's moving cross-country so I'm hoping you guys can give me some advice.
The script is supposed to return a total shipping price based on the weight of products that are passed to it via an API and the location of the visitor. There are a total of 3 different products (Product A, Product B, Product C) each with it's own weight in grams and it's own shipping rate. The script is needs to follow the following rules:
When 1 product (either Product A, B, or C) is in the cart it returns the full fixed shipping price for either US or International Shipping based on $isInternational
When 2 or more of Product A or B are added to the cart the full shipping is taken for the heaviest item and a fixed price is added for each additional item (Product and B each have their own fixed prices)
When Product C is added to the cart it returns a fixed based on US or International (Product C ships separately and doesn't depend on the weight/prices of Product A or B)
The product weights/prices a
Product A: Hi there Does anyone know where can i get php/mysql calculation weight & shipping cost tutorial ? Thank you in advanced! Hi there, I am working on an e-commerce website on PHP and MySql. The website has products that suppliers can add and edit, which works fine. Now we are required to create and add a shipping profile to the products. That is, a supplier can set up a profile where he'll specify, for example: Setting Shipping charges of Product weight $10/kg for US shipping $20/Kg for Europe $25/Kg for Rest of the world. Once this profile is setup, I would need to attach this profile to a product. Well, I can create a table named ProductProfile and enter this weight info and how do I go about attaching this to a product. Any comment/feedback are always welcome! Thank you Posted this in the help section but I realized I would have better luck posting this in this forum.
I need some urgent help with a simple script a friend wrote for me but isn't returning the correct values. I'm looking to get this script working but my PHP skills are abysmal and I can't for the life of me figure out whats the best way to do this. I've tried contacting my friend but he's moving cross-country so I'm hoping someone could help me quickly. I require the script to be working for a small project of mine so I need some help within the next 3-4 hrs if possible.
The script is supposed to return a total shipping price based on the weight of products that are passed to it via an API and the location of the visitor. There are a total of 3 different products (Product A, Product B, Product C) each with it's own weight in grams and it's own shipping rate. The script is needs to follow the following rules:
When 1 product (either Product A, B, or C) is in the cart it returns the full fixed shipping price for either US or International Shipping based on $isInternational
When 2 or more of Product A or B are added to the cart the full shipping is taken for the heaviest item and a fixed price is added for each additional item (Product and B each have their own fixed prices)
When Product C is added to the cart it returns a fixed based on US or International (Product C ships separately and doesn't depend on the weight/prices of Product A or B)
The product weights/prices a
Product A: I have couple of shipping methods DHL & FedEx, if selected products exits in cart show only selected shipping method, how to archive using shopping cart pricing rule or any other way to do this?
I am using extra fees extension, if customer chooses shipping method: Pick from the store how to remove Handling fees(extra fees extension).
How to solve by using observer? Edited August 12, 2019 by aveevaI'm wondering how I can use the following code to capture the current url...... Code: [Select] <?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } ?> <?php echo curPageURL(); ?> and then have the output modified to change the domain name and create a link. Example: before - http://website1.com/page after - http://website2.com/page I think this would be done using function modify_url, but I'm not sure how to do it, any help would be greatly appreciated. Thanks Greetings experts, Please forgive me for this cheap question. I have got a calendar of events and displays events for 7 departments. For each department, we would like the calendar to display events specific to that department. The way I am thinking about doing this is to grab the department from the url and compare it with the department on the db for which events is inserted into the db with. If there is a match, then display the events for that department. Something like: $tquery = "select * from ".$EVENTS_TB." where ".$EVENTS_TB.".month='".$smmonth."' and ".$EVENTS_TB.".year='".$smyear."' and ".$EVENTS_TB.".deptid='deptFromQueryString' " ; The problem that I have is that I don't in php, how to capture the querystring from url. For instance, assume this is the url: http://www.domain.com/departName. DeparmentName represents the department value. How do I capture the query above? Thanks so much. hi i am working on a php form where i need to get user signature and store in a db or as file, here is a link to an applet with perl but i am not sure about it. i need something like this http://www.lawrencegoetz.com/programs/signature/ Please can anyone tell if there is something related for php. thanks for any suggestion. Hi everyone, thanks for reading. I have live HTTP headers installed on Firefox, hopefully some of you will be familiar with this addon. I would like to make a php script that is able to do what live http headers does, that is, I'd like to be able to give the script a URL and it will return all the headers. I know how to use CURLOPT_HEADER and CURLOPT_RETURNTRANSFER but this doesn't quite do what I'm looking for. For example if I go to : https://adwords.google.com/o/Targeting/Explorer?__c=1000000000&__u=1000000000&ideaRequestType=KEYWORD_STATS#search.none with Live HTTP Headers switched on I get the following data under the 'generators' tab GET /o/Targeting/Explorer?__c=1000000000&__u=1000000000&ideaRequestType=KEYWORD_STATS GET /cues/cues.js GET /ga.js GET /cues/cb?__u=1000000000&__c=1000000000&l=en_US&v=5E5BE5A3D9AD806BA7FF2C9FE2E15DF9&a=1000000000 GET /cues/metrics/?requestType=external&startTime=1287073462287&browserStartTime=1287073471028&browserEndTime=1287073472156 GET /cues/metrics/?requestType=notabs&startTime=1287073462287&browserStartTime=1287073471028&browserEndTime=1287073472162 GET /o/Targeting/clear.cache.gif GET /__utm.gif?utmwv=4.8.6&utmn=606563096&utmhn=adwords.google.com&utmcs=UTF-8&utmsr=1280x1024&utmsc=24-bit&utmul=en-gb&utmje=1&utmfl=10.1%20r85&utmdt=Google%20AdWords%3A%20Traffic%20Estimator&utmhid=1700273830&utmr=-&utmp=%2FAnonymous%2FTargetingExplorer%2FKeywordStats%3Fcontext%3DHistoryChange%26__c%3D1000000000%26__u%3D1000000000%26ideaRequestType%3DKEYWORD_STATS&utmac=UA-3418223-1&utmcc=__utma%3D229779660.119716289.1279381615.1286975241.1287071773.41%3B%2B__utmz%3D229779660.1279381615.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B&utmu=q GET /o/Targeting/F098CA184E661C697D29595B67C57BAA.cache.png GET /favicon.ico POST /o/Targeting/captcha?__u=1000000000&__c=1000000000&challengedService=/o/Targeting/g 6|1|4|https://adwords.google.com/o/Targeting/|02990CDDCF521142AE1B373ED2008D94|_|getToken|1|2|3|4|0| GET /o/Targeting/captchaData?token=AJtyWwbzrehZWrT8puwruvcvjxCHnRJWKqWvpWfw54W2AjmF2cAlFpYLcL13KE0hi7retjZclcFHqnd8yMC0vDfP4tRNXISZ1QfbdLBK_WVW1wqlzqrR2ouSBgclxUiU0RiHUXHWy1VrIlo5oq3xNeemD-dZHQr0ed1s6p-dBF9mvyvkct1BifkXPAD___W32qxemYPbi6qvgpec3-rgsesGVUoYPglxzg&type=IMAGE GET /favicon.ico However my current CURL script only returns the following HTTP/1.1 200 OK Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: Fri, 01 Jan 1990 00:00:00 GMT Date: Thu, 14 Oct 2010 17:05:12 GMT Content-Type: text/html; charset=UTF-8 X-Invoke-Duration: 8 X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Server: GSE Transfer-Encoding: chunked This is my script so far <?php $url="https://adwords.google.com/o/Targeting/Explorer?__c=1000000000&__u=1000000000&ideaRequestType=KEYWORD_STATS#search.none"; $useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; //next open a new CURL session $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_USERAGENT, $useragent); curl_setopt ($ch, CURLOPT_HEADER, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_FRESH_CONNECT, 0); curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem"); $source=curl_exec($ch); //the source code is now stored in $source, lets close the curl session curl_close($ch); echo $source; ?> Greetings, 1- Write a PHP program that goes through all integers between 1 and 100 (excluding 1 and 0) and displays each even number on a separate line. 2- Re-write the program in question 1 but this time use a function to go through the numbers and display them. I have the following. How can I do the other one? <?php for ($i = 2; $i <= 100; $i++) { if ($i % 2 == 0){ print $i . " <Br> "; } } ?> |