| 1 |
<?php namespace TierPricingTable\Integrations\Plugins; |
| 2 |
|
| 3 |
use TierPricingTable\PriceManager; |
| 4 |
use WC_Product; |
| 5 |
|
| 6 |
class AddifyRequestAQuote extends PluginIntegrationAbstract { |
| 7 |
|
| 8 |
public function run() { |
| 9 |
add_filter( 'addify_quote_item_product', function ( WC_Product $product, $quoteItem ) { |
| 10 |
$quantity = $quoteItem['quantity'] ? intval( $quoteItem['quantity'] ) : 1; |
| 11 |
|
| 12 |
$pricingRule = PriceManager::getPricingRule( $product->get_id() ); |
| 13 |
|
| 14 |
$price = $pricingRule->getTierPrice( $quantity, false, 'cart' ); |
| 15 |
|
| 16 |
if ( $price ) { |
| 17 |
$product->set_price( $price ); |
| 18 |
} |
| 19 |
|
| 20 |
return $product; |
| 21 |
}, 10, 2 ); |
| 22 |
} |
| 23 |
|
| 24 |
public function getIconURL(): string { |
| 25 |
return $this->getContainer()->getFileManager()->locateAsset( 'admin/integrations/addify-raq-icon.png' ); |
| 26 |
} |
| 27 |
|
| 28 |
public function getAuthorURL(): string { |
| 29 |
return 'https://woocommerce.com/products/request-a-quote-plugin-for-woocommerce/'; |
| 30 |
} |
| 31 |
|
| 32 |
public function getTitle(): string { |
| 33 |
return 'Request a Quote for WooCommerce by Addify'; |
| 34 |
} |
| 35 |
|
| 36 |
public function getDescription(): string { |
| 37 |
return __( 'Apply tiered pricing discounts when users request a quote through the Addify Request a Quote form.', 'tier-pricing-table' ); |
| 38 |
} |
| 39 |
|
| 40 |
public function getSlug(): string { |
| 41 |
return 'addify-request-a-quote'; |
| 42 |
} |
| 43 |
|
| 44 |
public function getIntegrationCategory(): string { |
| 45 |
return 'other'; |
| 46 |
} |
| 47 |
} |
| 48 |
|