-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from melhorenvio/feature/add-compatibility-pl…
…ugins-composite
- Loading branch information
Showing
29 changed files
with
683 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace MelhorEnvio\Factory; | ||
|
||
use Exception; | ||
|
||
class ProductServiceFactory | ||
{ | ||
/** | ||
* @throws Exception | ||
*/ | ||
public static function fromProduct($product) | ||
{ | ||
switch ($product->get_type()) { | ||
case 'woosb': | ||
return new \MelhorEnvio\Services\Products\BundleService(); | ||
case 'composite': | ||
return new \MelhorEnvio\Services\Products\CompositeService(); | ||
default: | ||
return new \MelhorEnvio\Services\Products\ProductsService(); | ||
} | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public static function fromId($productId) | ||
{ | ||
$product = wc_get_product($productId); | ||
|
||
return self::fromProduct($product); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace MelhorEnvio\Models; | ||
|
||
class Product | ||
{ | ||
public $id; | ||
public $name; | ||
public $quantity; | ||
public $weight; | ||
public $height; | ||
public $width; | ||
public $length; | ||
public $unitary_value; | ||
public $insurance_value; | ||
public $type; | ||
public $is_virtual; | ||
public $components = []; | ||
public $parentId; | ||
public $pricing; | ||
public $shipping_fee; | ||
|
||
public function setValues($value){ | ||
$this->unitary_value = (float) $value; | ||
$this->insurance_value = (float) $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
|
||
class Version { | ||
|
||
const VERSION = '2.15.0'; | ||
const VERSION = '2.15.1'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.