Created
December 7, 2016 16:04
-
-
Save goldhat/5dd7a4d7fdf64dfbefa24f73a29044ba to your computer and use it in GitHub Desktop.
subscriptionsAvailableTest()
This file contains hidden or 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
public function subscriptionsAvailableTest() { | |
$settings = new LiveGlam_WaitlistSettings; | |
$io = new LiveGlam_InventoryOrder; | |
// get settings and convert to ratio for calculations | |
$replacement = $settings->getReplacementPercentage() / 100; | |
$buffer = $settings->getActivationBuffer() / 100; | |
// get orderLimit for period | |
$orderLimit = $io->getNextOrderLimitByCategory( $this->productCategory ); | |
$replacementUnits = $orderLimit * $replacement; | |
$bufferUnits = $orderLimit * $buffer; | |
$activationCap = $orderLimit - $replacementUnits - $bufferUnits; | |
// get shippable count | |
$shippableCount = LiveGlam_SubscriberCount::getShippable( $this->productCategory ); | |
// if activationCap greater, we can activate the difference | |
if( $activationCap > $shippableCount ) { | |
return $activationCap - $shippableCount; | |
} | |
// no room to activate | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment