AdminHooks.php
1 week ago
DefaultConversion.php
1 week ago
FlatRateShipping.php
5 years ago
FreeShipping.php
1 week ago
FrontEndHooks.php
1 week ago
LocalPickup.php
5 years ago
ShippingClasses.php
1 week ago
ShippingClassesMode.php
1 week ago
ShippingHooksFactory.php
1 week ago
ShippingMode.php
1 week ago
ShippingModeBase.php
1 week ago
ShippingModeProvider.php
1 week ago
UnsupportedShipping.php
1 week ago
VariableCost.php
1 week ago
ShippingModeProvider.php
31 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\Multicurrency\Shipping; |
| 4 | |
| 5 | class ShippingModeProvider { |
| 6 | |
| 7 | private static function getClasses() { |
| 8 | $collection = wpml_collect( [ |
| 9 | 'flat_rate' => 'WCML\Multicurrency\Shipping\FlatRateShipping', |
| 10 | 'free_shipping' => 'WCML\Multicurrency\Shipping\FreeShipping', |
| 11 | 'local_pickup' => 'WCML\Multicurrency\Shipping\LocalPickup', |
| 12 | ] ); |
| 13 | return $collection; |
| 14 | } |
| 15 | |
| 16 | public static function getAll() { |
| 17 | return self::getClasses()->map( function( $className ) { |
| 18 | return self::make( $className ); |
| 19 | } ); |
| 20 | } |
| 21 | |
| 22 | public static function get( $shippingMode ) { |
| 23 | return self::make( |
| 24 | self::getClasses()->get( $shippingMode, 'WCML\Multicurrency\Shipping\UnsupportedShipping' ) |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | private static function make( $className ) { |
| 29 | return \WPML\Container\make( $className ); |
| 30 | } |
| 31 | } |