コード例 #1
0
                            $voucher->description[$lang['id_lang']] = $name[$sel];
                        }
                        $voucher->name = $code;
                        if ($trigger[$sel]['discountType'] == 'amount') {
                            $voucher->id_discount_type = 2;
                        } else {
                            $voucher->id_discount_type = 1;
                        }
                        $voucher->value = $trigger[$sel]['discount'];
                        $voucher->quantity = 1;
                        $voucher->quantity_per_user = 1;
                    }
                    $voucher->id_customer = $customer['id_customer'];
                    $voucher->date_from = date('Y-m-d');
                    $voucher->date_to = date('Y-m-d', time() + 31 * 24 * 3600);
                    $voucher->active = 1;
                    $voucher->add();
                }
                /* mail sending */
                if ($res = $mailjet->sendMail($subject, $temp, $customer['email'])) {
                    DB::getInstance()->execute('
						INSERT INTO `' . _DB_PREFIX_ . 'mj_trigger`(id_customer,id_target,type,date)
						VALUES(' . $customer['id_customer'] . ',' . $customer[$sql_target[$sel]] . ',' . $sel . ',\'' . date('Y-m-d') . '\')');
                }
            }
        }
    }
    echo 'OK';
} else {
    echo 'KO';
}