Skip to content

Commit

Permalink
fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
timoj committed Dec 12, 2017
2 parents e112b40 + 8a7aaf6 commit c9d97ad
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
37 changes: 24 additions & 13 deletions includes/wcwuunder-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class WC_Wuunder_Create
{
public $order_id;
private $version_obj = array("product" => "Woocommerce extension", "version" => array("build" => "2.1.1", "plugin" => "2.0"));
private $version_obj = array("product" => "Woocommerce extension", "version" => array("build" => "2.1.2", "plugin" => "2.0"));

public function __construct()
{
Expand Down Expand Up @@ -49,7 +49,14 @@ private function buildWuunderData($orderId)
$orderItems = $this->get_order_items($orderId);
$orderMeta = get_post_meta($orderId);
$order = new WC_Order($orderId);
$orderPicture = $this->get_base64_image($orderItems['images'][0]);
$orderPicture = null;
foreach ($orderItems['images'] as $image) {
if (!is_null($image)) {
$orderPicture = $this->get_base64_image($image);
break;
}
}


$defLength = 80;
$defWidth = 50;
Expand All @@ -63,16 +70,16 @@ private function buildWuunderData($orderId)

$totalWeight = 0;
$dimensions = null;
$description = null;
$description = "";

foreach ($orderItems['products'] as $item) {
$totalWeight += $item['total_weight'];
if ($dimensions === null) {
$dimensions = explode(' x ', $item['dimensions']);
}
if ($description === null) {
$description = $item['name'];
}
// if ($description === null) {
$description .= "- " . $item['name'] . "\r\n";
// }
}

if ($totalWeight === 0) {
Expand Down Expand Up @@ -150,7 +157,6 @@ public function generateBookingUrl()
preg_match("!\r\n(?:Location|URI): *(.*?) *\r\n!i", $header, $matches);
$url = $matches[1];

//var_dump($wuunderData);
// Close connection
curl_close($cc);

Expand Down Expand Up @@ -325,12 +331,17 @@ public function get_base64_image($picture)
{

$imagepath = $picture;
$imagetype = pathinfo($imagepath, PATHINFO_EXTENSION);
$imagedata = file_get_contents($imagepath);
$image = base64_encode($imagedata);

return $image;

try {
if (filesize($imagepath) <= 2097152) { //smaller or equal to 2MB
$imagedata = file_get_contents($imagepath);
$image = base64_encode($imagedata);
} else {
$image = "";
}
return $image;
}catch(Exception $e) {
return "";
}
}

public function add_listing_actions($order)
Expand Down
4 changes: 2 additions & 2 deletions woocommerce-wuunder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WooCommerce Wuunder
* Plugin URI: http://wearewuunder.com
* Description: Wuunder shipping plugin
* Version: 2.1.1
* Version: 2.1.2
* Author: Wuunder
* Author URI: http://wearewuunder.com
*/
Expand Down Expand Up @@ -49,7 +49,7 @@ class Woocommerce_Wuunder
public static $plugin_path;
public static $plugin_basename;

const VERSION = '2.1.1';
const VERSION = '2.1.2';

public function __construct()
{
Expand Down

0 comments on commit c9d97ad

Please sign in to comment.