Skip to content

Instantly share code, notes, and snippets.

@goldhat
Created December 7, 2016 16:04
Show Gist options
  • Save goldhat/5dd7a4d7fdf64dfbefa24f73a29044ba to your computer and use it in GitHub Desktop.
Save goldhat/5dd7a4d7fdf64dfbefa24f73a29044ba to your computer and use it in GitHub Desktop.
subscriptionsAvailableTest()
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