opencart2.0.1.1
USPS setting:-Weight Class= Pound, Geo Zone= All Zones, Dimensions (L x W x H)=10x10x10, Zip Code=33446
product:- Weight Class = Pound, Dimensions (L x W x H)=10x10x10, Weight =4.
it is working properly in Domestic Services But International Services is not showing when i m checkout using other country(Mexico),
I just find out $this->config->get('usps_girth') not returning any value,
So i use formula to find out girth = L + W * 2 + H * 2 ;
In \catalog\model\shipping\usps.php i have changed at line 300 aprx.
From usps.php
$xml .= ' <Container>' . $this->config->get('usps_container') . '</Container>';
$xml .= ' <Size>' . $this->config->get('usps_size') . '</Size>';
$xml .= ' <Width>' . $this->config->get('usps_width') . '</Width>';
$xml .= ' <Length>' . $this->config->get('usps_length') . '</Length>';
$xml .= ' <Height>' . $this->config->get('usps_height') . '</Height>';
$xml .= ' <Girth>' . $this->config->get('usps_girth') . '</Girth>';
$xml .= ' <CommercialFlag>N</CommercialFlag>';
$xml .= ' </Package>';
$xml .= '</IntlRateV2Request>';
$request = 'API=IntlRateV2&XML=' . urlencode($xml);
To usps.php
//$this->config->get('usps_girth') -> to -> girth = L + W * 2 + H * 2
$girth =($this->config->get('usps_width'))+(($this->config->get('usps_length'))*2)+(($this->config->get('usps_height'))*2);
$xml .= ' <Container>' . $this->config->get('usps_container') . '</Container>';
$xml .= ' <Size>' . $this->config->get('usps_size') . '</Size>';
$xml .= ' <Width>' . $this->config->get('usps_width') . '</Width>';
$xml .= ' <Length>' . $this->config->get('usps_length') . '</Length>';
$xml .= ' <Height>' . $this->config->get('usps_height') . '</Height>';
$xml .= ' <Girth>' . $girth . '</Girth>';
$xml .= ' <CommercialFlag>N</CommercialFlag>';
$xml .= ' </Package>';
$xml .= '</IntlRateV2Request>';
$request = 'API=IntlRateV2&XML=' . urlencode($xml);
Related
I have this code:
$passwordsParameters = "sysPassword = 12 &&& testPass = 13 &&& systemPassword = 10"
$parametersList = #($passwordsParameters -split '&&&')
$passwordsTable = #{}
ForEach ($parameter in $parametersList) {
$splitToKeyValue = #($parameter -split '=')
$passwordsTable += $passwordsTable = #{
$splitToKeyValue[0].trim() = $splitToKeyValue[1].trim()
}
}
ForEach ($pass in $passwordsTable.Keys) {
if ($passwordsTable[$pass] -ne "") {
Write-Host "set $pass ="$passwordsTable[$pass]""
} else {
Write-Host "A value for the parameter $pass was not entered."
}
}
# Add-Content "d:\myFile.txt" "set $pass ="$passwordsTable[$pass]""
Which perfectly works when I use Write-Host. But I want to do something like in the comment in line 25. I tried several ways but I always got a static string instead of the values that I get from the Hashtable.
At the end I want to have something like:
set pass1 = 12
set pass2 = 5
in myFile.txt
Any help is appreciated. Thanks!
You could change Write-Host (just prints to a console) to Write-Output ( which passes an object to a pipeline). Write-Output does not print to the console.
$passwordsParameters = "sysPassword = 12 &&& testPass = 13 &&& systemPassword = 10"
$parametersList = #($passwordsParameters -split '&&&')
$passwordsTable = #{}
ForEach ($parameter in $parametersList) {
$splitToKeyValue = #($parameter -split '=')
$passwordsTable += $passwordsTable = #{
$splitToKeyValue[0].trim() = $splitToKeyValue[1].trim()
}
}
$counter=0
ForEach ($pass in $passwordsTable.Keys) {
if ($passwordsTable[$pass] -ne "") {
$counter++
Write-Output "set "pass$counter = $passwordsTable[$pass]"`n" | Add-Content -NoNewline myFile.txt
} else {
Write-Host "A value for the parameter $pass was not entered."
}
}
Output:
set pass1=10
set pass2=13
set pass3=12
You can replace the first foreach loop if you simply replace all the &&& by a newline and use cmdlet ConvertFrom-StringData.
Add-Content also has a switch called -PassThru that will let you write to the file and also output to console.
$passwordsParameters = "sysPassword = 12 &&& testPass = 13 &&& systemPassword = 10"
$passwordsTable = $passwordsParameters -replace '&&&', [Environment]::NewLine | ConvertFrom-StringData
foreach ($pass in $passwordsTable.Keys) {
if ($passwordsTable[$pass]) {
$msg = 'set {0} = {1}' -f $pass, $passwordsTable[$pass]
# or use: $msg = "set $pass = $($passwordsTable[$pass])"
# write this to the file. switch -PassThru will also output to the console
Add-Content -Path 'D:\myFile.txt' -Value $msg -PassThru
} else {
Write-Host "A value for the parameter '$pass' was not entered."
}
}
I have in my PHP file this string :
$sql = "SELECT p.pac_rut a, ";
$sql .= " p.pac_dig b, ";
$sql .= " p.pac_apepat c, ";
$sql .= " p.pac_apemat d, ";
$sql .= " p.pac_nombre e, ";
$sql .= " to_char(p.pac_fecha_nac,'dd/mm/yyyy') as f, ";
$sql .= " (to_char(sysdate,'yyyy')-to_char(p.pac_fecha_nac,'yyyy')) as g, ";
$sql .= " p.sex_cod h ";
$sql .= "FROM mytable ";
$sql .= "WHERE p.pac_rut=$rut";
And sed ':a;N;$!ba;s/\n//g' | sed 's/"; $sql .= "//g' | sed 's/ //g' | sed 's/=\$/=:/g' gives me the result ok like : $sql= "SELECT p.pac_rut a,p.pac_dig b,p.pac_apepat c,p.pac_apemat d,p.pac_nombre e,to_char(p.pac_fecha_nac,'dd/mm/yyyy') as f,(to_char(sysdate,'yyyy')-to_char(p.pac_fecha_nac,'yyyy')) as g,p.sex_cod h FROM salud.pacientes p WHERE p.pac_rut=:rut";
But if a have 2 (or more) blocks of sql queries, i need a function which can build 2 (or more) queries sql on 2 (or more) lines.
For ejample, i have :
$sql = "SELECT p.pac_rut a ";
$sql .= "FROM mytable ";
$sql .= "WHERE p.pac_rut=$rut";
and
$sql2 = "SELECT p.pac_rut a ";
$sql2 .= "FROM mytable ";
$sql2 .= "WHERE p.pac_rut=$rut";
in the same file, i need this result :
$sql = "SELECT p.pac_rut a FROM mytable WHERE p.pac_rut=$rut";
$sql2 = "SELECT p.pac_rut a FROM mytable WHERE p.pac_rut=$rut";
How can i do that with awk or sed or other linux tool ?
I have such a code for exporting Excel file with two worksheets into two csv files.The problem is that I am currently exporting whole worksheets and I want to export only these 3 columns from my loop.How can I save them? They must be in order because I want to import it later to AD.
Function ExportWSToCSV ($excelFileName , $csvLoc){
#Sample use in a console: ExportWSToCSV -excelFileName "Test_Peoplesoft.xls" -csvLoc "y:\Application Data\CSVFiles\"
$CultureOld = [System.Threading.Thread]::CurrentThread.CurrentCulture
#Original culture info
$CultureUS = [System.Globalization.CultureInfo]'en-US'
#US culture info
$excelFile = "y:\Application Data\Test_Peoplesoft.xls"
#Loc of Excel file .xls , #csvLov - Loc of output files in format .csv
[System.Threading.Thread]::CurrentThread.CurrentCulture = $CultureUS
$E = New-Object -ComObject Excel.Application
$E.Visible = $false
$E.DisplayAlerts = $false
$wb = $E.Workbooks.Open($excelFile)
$intRow = 2
$intRowMax =($ws.UsedRange.Rows).count
$elements = $email -or $costcode -or $leader
Do{
foreach($ws in $wb.sheets.item("Inactive")){
if($elements -ne $null ){
$email = $ws.Cells.Item($intRow, 4).Value()
$costcode = $ws.Cells.Item($intRow, 15).Value()
$leader = $ws.Cells.Item($intRow, 20).Value()
}else{Write-Host "Null Value in one of the attributes"}
}
<#
foreach($ws in $wb.sheets.item("Inactive")){
$email = $ws.Cells.Item($intRow, 4).Value()
$costcode = $ws.Cells.Item($intRow, 15).Value()
$leader = $ws.Cells.Item($intRow, 20).Value()
}
#>
$user = $email + "_" + $costcode + "_" + $leader
write-host $intRow " " $user
$intRow++
}While ($ws.Cells.Item($intRow,1).Value() -ne $null)
foreach ($ws in $wb.Worksheets)
{
Write-Host "Processing Worksheet: " $ws.Name
$n = $csvLoc + $excelFileName + "_" + $ws.Name
#Name variable - Output file loc + excel file name + worksheet name
$ws.SaveAs($n + ".csv", 6)
#Saving file to .csv
}
$E.Quit()
[System.Threading.Thread]::CurrentThread.CurrentCulture = $CultureOld
}
Something like this should work:
First, setup an array for containing our list of exported users like so:
$exportList = #()
(place before you start looping the rows)
Then loop through the rows on your worksheet with your do while loop and add a user object to add the your export list like so
# Create userObj with the required properties
$userObj = New-Object System.Object
$userObj | Add-Member -Type NoteProperty -Name Email -Value $email
$userObj | Add-Member -Type NoteProperty -Name CostCode -Value $costcode
$userObj | Add-Member -Type NoteProperty -Name Leader -Value $leader
# Add $userObj to our list to be exported
$exportList += $userObj
And ofcourse export it to .csv
$exportList | Export-Csv $pathToCsvFile
I want to import sing column of excel sheet into database table name admin_record and excel sheet is only consist of one column and name of the column is bar codes and rows can be many.
I want to save it in database my table name is admin_record and its consists of only two fields
id (which is primary key)
bar_code.
find only this code which i totally cant understand
public function read_file($table = 'admin_record', $filename = 'example.xls') {
$pathToFile = 'uploads/' . $filename;
$this->load->library('Spreadsheet_Excel_Reader');
$data = new Spreadsheet_Excel_Reader($pathToFile);
$sql = "INSERT INTO $table (";
for($index = 1;$index <= $data->sheets[0]['numCols']; $index++){
$sql.= strtolower($data->sheets[0]['cells'][1][$index]) . ", ";
}
$sql = rtrim($sql, ", ")." ) VALUES ( ";
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
$valuesSQL = '';
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
$valuesSql .= "\"" . $data->sheets[0]['cells'][$i][$j] . "\", ";
}
echo $sql . rtrim($valuesSql, ", ")." ) <br>";
}
}
your library file is wrong please use following link to download
Spreadsheet_Excel_Reader Library
public function my_test($table = 'admin_record', $filename = 'resources/uploads/c.xls')
{
$pathToFile = $filename;
$valuesSql="";
$this->load->library('Spreadsheet_Excel_Reader');
$data = new Spreadsheet_Excel_Reader($pathToFile);
$sql = "INSERT INTO $table (";
for($index = 1;$index <= $data->sheets[0]['numCols']; $index++){
$sql.= strtolower($data->sheets[0]['cells'][1][$index]) . ", ";
}
$sql = rtrim($sql, ", ")." ) VALUES ( ";
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
$valuesSQL = '';
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
$valuesSql .= "\"" . $data->sheets[0]['cells'][$i][$j] . "\", ";
}
echo $sql . rtrim($valuesSql, ", ")." ) <br>";
} // add this line
}
When the site owner receives an email based on form input, I want there to be bold labels...
Like this...
Name: $name
Phone: $phone
Email Address: $email
etc, etc...
But they're not displaying correctly.
Here's the way I have the email set up...
$msg = "You have been contacted by $name with regards to $subject. Their message is as follows:";
$msg .= "" . PHP_EOL;//Line Break
$msg .= "Name:".$name . PHP_EOL . PHP_EOL;
$msg .= "Phone:".$phone . PHP_EOL . PHP_EOL;
$msg .= "Email Address:".$email . PHP_EOL . PHP_EOL;
$msg .= "Low Budget:".$budgetlow . PHP_EOL . PHP_EOL;
$msg .= "High Budget:".$budgethigh . PHP_EOL . PHP_EOL;
$msg .= "Venue Name:".$venuename . PHP_EOL . PHP_EOL;
$msg .= "Event Capacity:".$eventcapacity . PHP_EOL . PHP_EOL;
$msg .= "<strong>Event Description:</strong>".$eventdescription . PHP_EOL . PHP_EOL;
$msg .= "" . PHP_EOL . PHP_EOL; //Line Break
$msg .= "You can contact $name via email at $email or via phone at $phone." . PHP_EOL . PHP_EOL;
I want the labels to show up in bold. Above, I've added tags to Event Description to try and bold it, but it doesn't come out bold.
Here is how I have my headers set up...
$headers = "From: $email" . PHP_EOL;
$headers .= "Reply-To: $email" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-Type: text/plain; charset=us-ascii" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;
You're sending a plain text email, but you're trying to make parts of it bold by including <strong> tags.
This won't work. A plain text email will only ever be displayed as plain text. If you want to send it with HTML markup, you need to make the whole thing into an HTML document, and send it with the HTML content type.
I would also strongly recommend using a decent PHP mailer library such as phpMailer or Swiftmailer. This will make it a lot easier to send HTML formatted emails -- you'll be able to get rid of all the code you have to setup the headers entirely; the library will take care of all this sort of thing for you.
[EDIT]
Okay, just to prove how easy this is, how about I give you some code to demonstrate? Let's assume you use phpMailer. Your code would look like this:
//somewhere at the top of your program
require('/path/to/phpMailer.class.php');
//your existing $msg code, but with <br> tags instead of PHP_EOL
$msg = ....
//this bit replaces your header block...
$mail = new PHPMailer();
$mail->From = 'from#example.com';
$mail->AddReplyTo('info#example.com', 'Information');
$mail->AddAddress('recipient#example.net');
$mail->IsHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body = $msg;
//and send it (replaces the call to php's mail() function)
$mail->send();
It really is that easy. Seriously. Especially if you're a beginner, you are a lot more likely to get it right doing it this way than trying to hand-code your mail header. That's just crazy.
But more importantly, it adds a whole stack of other features.
Want to include attachements? Without the library, it would be a mountain of code. With phpMailer, it's a single extra line.
Security. phpMailer will validate the addresses and other fields, and prevent hackers from using your system to send spam (if you're writing your own headers, the odds are strong that you're vulnerable to attack).
Sending to multiple recipients? Just call AddAddress multiple times.