| 1 |
<?php namespace TierPricingTable\Integrations\Plugins; |
| 2 |
|
| 3 |
use TierPricingTable\PriceManager; |
| 4 |
|
| 5 |
class WCCS extends PluginIntegrationAbstract { |
| 6 |
|
| 7 |
public function run() { |
| 8 |
|
| 9 |
add_filter( 'tiered_pricing_table/price/price_by_rules', |
| 10 |
function ( $product_price, $quantity, $product_id, $context ) { |
| 11 |
|
| 12 |
global $WCCS; |
| 13 |
|
| 14 |
if ( $WCCS ) { |
| 15 |
|
| 16 |
$product = wc_get_product( $product_id ); |
| 17 |
|
| 18 |
if ( 'view' === $context && $product ) { |
| 19 |
return $WCCS->wccs_custom_price( $product_price, $product ); |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
return $product_price; |
| 24 |
|
| 25 |
}, 10, 10 ); |
| 26 |
|
| 27 |
add_filter( 'tiered_pricing_table/cart/product_cart_price', |
| 28 |
function ( $price, $cartItem, $cartItemKey, $totalQuantity ) { |
| 29 |
|
| 30 |
global $WCCS; |
| 31 |
|
| 32 |
if ( ! $WCCS ) { |
| 33 |
return $price; |
| 34 |
} |
| 35 |
|
| 36 |
if ( $price ) { |
| 37 |
return PriceManager::getPriceByRules( $totalQuantity, $cartItem['data']->get_id(), 'edit', 'cart', |
| 38 |
false ); |
| 39 |
} |
| 40 |
|
| 41 |
return $price; |
| 42 |
}, 10, 4 ); |
| 43 |
} |
| 44 |
|
| 45 |
public function getTitle(): string { |
| 46 |
return __( 'WooCommerce Currency Switcher by WP Experts (WCCS)', 'tier-pricing-table' ); |
| 47 |
} |
| 48 |
|
| 49 |
public function getDescription(): string { |
| 50 |
return __( 'Make the tiered pricing properly work with multiple currencies.', 'tier-pricing-table' ); |
| 51 |
} |
| 52 |
|
| 53 |
public function getIconURL(): string { |
| 54 |
return $this->getContainer()->getFileManager()->locateAsset( 'admin/integrations/wccs-icon.png' ); |
| 55 |
} |
| 56 |
|
| 57 |
public function getAuthorURL(): string { |
| 58 |
return 'https://woocommerce.com/products/currency-switcher-for-woocommerce/'; |
| 59 |
} |
| 60 |
|
| 61 |
public function getSlug(): string { |
| 62 |
return 'wccs'; |
| 63 |
} |
| 64 |
|
| 65 |
public function getIntegrationCategory(): string { |
| 66 |
return 'multicurrency'; |
| 67 |
} |
| 68 |
} |
| 69 |
|