Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#26 10-22-2015 12:06:51

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Royal Mail DMO csv file

You wrote:

Code:

      $cartdata = unserialize($item['cartdata']);
      $item['shipweight'] = $item['cartdata']; 

...{$item['shipweight']}

I wrote:

Code:

     $cartdata   = unserialize($item['cartdata']);
     $shipweight = $cartdata['shipweight'];

...{$shipweight}

Your error is with '=$item['cartdata']'.  Should be '=$cartdata['shipweight']'.


Nick Hendler

Offline

 

#27 10-22-2015 12:20:01

nigel
Member
From: Peterborough, UK
Registered: 04-27-2008
Posts: 418
Website

Re: Royal Mail DMO csv file

Hi Nick,

this is how my code looks now but it does not populate the cell in the spreadsheet.

Code:

foreach ($items as $num => $item) {
      $cartdata   = unserialize($item['cartdata']);
     $shipweight = $cartdata['shipweight']; 
      
     $export_file1 .= "\"{$order['id']}\",";
     $export_file1 .= "\"{$item['fname']} {$item['lname']}\",\"{$item['company']}\",\"{$item['addone']}\",\"{$item['addtwo']}\",\"\",\"{$item['city']}\",";
     $export_file1 .= "\"{$item['postalcode']}\",\"{$item['country']}\",\"\",\"{$order['email']}\",";
     $export_file1 .= "\"SR1\",\"CRL1\",\"\",\"\",\"LL\",\"1\",\"{$shipweight}\",\"{$order['datestamp']}\",\"\"" . $eol;
     
      } // End of foreach statement.

Offline

 

#28 10-23-2015 07:39:54

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Royal Mail DMO csv file

I apologize.  I never checked the variable definition that you initially did.  Instead of:

Code:

$shipweight = $cartdata['shipweight'];

It should be:

Code:

$shipweight = 0; if (!(empty($cartdata['sinshipinfo']['shipweight']))) {$shipweight = $cartdata['sinshipinfo']['shipweight'];}

Nick Hendler

Offline

 

#29 10-23-2015 07:56:43

nigel
Member
From: Peterborough, UK
Registered: 04-27-2008
Posts: 418
Website

Re: Royal Mail DMO csv file

Hi Nick,

that just puts a "0" in the spreadsheet:

Code:

foreach ($items as $num => $item) {
      $cartdata = unserialize($item['cartdata']);
      $shipweight = 0; if (!(empty($cartdata['sinshipinfo']['shipweight']))) {$shipweight = $cartdata['sinshipinfo']['shipweight'];} 
      
     $export_file1 .= "\"{$order['id']}\",";
     $export_file1 .= "\"{$item['fname']} {$item['lname']}\",\"{$item['company']}\",\"{$item['addone']}\",\"{$item['addtwo']}\",\"\",\"{$item['city']}\",";
     $export_file1 .= "\"{$item['postalcode']}\",\"{$item['country']}\",\"\",\"{$order['email']}\",";
     $export_file1 .= "\"SR1\",\"CRL1\",\"\",\"\",\"LL\",\"1\",\"{$shipweight}\",\"{$order['datestamp']}\",\"\"" . $eol;
     
     } // End of foreach statement.

Offline

 

#30 10-26-2015 07:34:14

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Royal Mail DMO csv file

The weight should be in $cartdata['sinshipinfo']['shipweight'].  You can always do:

print_r($cartdata);

To see what's in the array.  I'm pretty sure that's the right set of keys.


Nick Hendler

Offline

 

Board footer