예제 #1
0
 /**
  * update period max cycles of recurring profile when cron job create order
  */
 public function updatePeriodMaxCycles()
 {
     // edit period max cycles if It is greater than or equal 0 and is numeric
     // If period max cycles <= 0 or null, recurring profile will run forever
     if ($periodMaxCycles = $this->_recurringProfile->getPeriodMaxCycles()) {
         if ((string) (int) $periodMaxCycles === ltrim($periodMaxCycles, '0') && $periodMaxCycles > 0) {
             $periodMaxCycles = (int) $periodMaxCycles - 1;
             $this->_recurringProfile->setPeriodMaxCycles($periodMaxCycles);
             $this->_recurringProfile->save();
         }
     }
 }