Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function afterSave($insert, $changedAttributes) {
- if (floatval($this->offer) >= floatval($this->product->threshold_price)) {
- $coupon = false;
- $createCoupon = "";
- $ctr = 1;
- while ($coupon == false) {
- $createCoupon = $this->createCoupon(
- "Offer for " . $this->customer_name . ' #' . $this->id,
- $this->product->sale_price - $this->offer,
- $this->product_id
- );
- if ($createCoupon || $ctr > 3) {
- $coupon = true;
- }
- $ctr++;
- }
- $this->status = self::STATUS_ACCEPTED_COUPON_GENERATED;
- $this->coupon_code = $createCoupon->code;
- // todo this
- // echo "Accepted automatically then send email to customer as the same time to merchant email";
- } else {
- $this->status = self::STATUS_REJECTED;
- }
- return parent::afterSave($insert, $changedAttributes);
- }
- public function afterSave($insert, $changedAttributes) {
- // So basically I want to update the status in afterSave
- $this->status = "What ever value rejected or accepted base of the outcome of generating coupon";
- $this->coupon = "AddTheCoupon";
- // Save or Update
- $this->save();
- return parent::afterSave($insert, $changedAttributes);
- }
Add Comment
Please, Sign In to add comment