当前位置: 首页>>代码示例>>PHP>>正文


PHP Page_Controller::getNonExpiringIsProductId方法代码示例

本文整理汇总了PHP中Page_Controller::getNonExpiringIsProductId方法的典型用法代码示例。如果您正苦于以下问题:PHP Page_Controller::getNonExpiringIsProductId方法的具体用法?PHP Page_Controller::getNonExpiringIsProductId怎么用?PHP Page_Controller::getNonExpiringIsProductId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Page_Controller的用法示例。


在下文中一共展示了Page_Controller::getNonExpiringIsProductId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createSubscription

 public function createSubscription($data, $form)
 {
     //Get member id
     $memberId = $data['MemberID'];
     //Get product id
     $productId = $data['ProductID'];
     // Get the Page controller
     $Page_Ctrl = new Page_Controller();
     //Get InfusionSoft Api
     $app = $Page_Ctrl->getInfusionSoftApi();
     // Get curent date
     $curdate = $app->infuDate(date('j-n-Y'));
     $member = Member::get()->byID($memberId);
     //Find or create the 'user' group and add the member to the group
     if (!($userGroup = DataObject::get_one('Group', "Code = 'customers'"))) {
         $userGroup = new Group();
         $userGroup->Code = "customers";
         $userGroup->Title = "Customers";
         $userGroup->Write();
         $userGroup->Members()->add($member);
     } else {
         $userGroup->Members()->add($member);
     }
     $isConID = $member->ISContactID;
     $product = Product::get()->byID($productId);
     // Get existing credit card ID
     $creditCard = $Page_Ctrl->getCurrentCreditCard($memberId);
     // Get the current InfusionSoft credit card ID
     $ccID = $creditCard->ISCCID;
     //Get siteconfig object
     $config = SiteConfig::current_site_config();
     //Process non-expiring heatmaps purchase
     if ($productId == 4 || $productId == 5 || $productId == 6 || $productId == 7) {
         if (!$data['Quantity']) {
             $form->addErrorMessage('Quantity', "Quantity is required for non-expiring products.", 'bad');
             return $this->edit(Controller::curr()->getRequest());
         }
         // Create an Infusionsoft order
         $invoiceId = $app->blankOrder($isConID, $product->Name, $curdate, 0, 0);
         $orderItem = $app->addOrderItem($invoiceId, intval($Page_Ctrl->getNonExpiringIsProductId($data['ProductID'])), 3, floatval($product->Price), intval($data['Quantity']), $product->Name, $product->Name);
         $result = $app->chargeInvoice($invoiceId, $product->Name, $ccID, $config->MerchantAccount, false);
         // Create an order
         $order = new Order();
         $order->OrderStatus = 'P';
         $order->Amount = $product->Price * $data['Quantity'];
         $order->MemberID = $member->ID;
         $order->ProductID = $data['ProductID'];
         $order->CreditCardID = $creditCard->ID;
         $orderID = $order->write();
         if ($result['Successful']) {
             // Add tag Paid member - prepaid
             $app->grpAssign($isConID, 2290);
             $conDat = array('ContactType' => 'AW Customer');
             $returnFields = array('_AttentionWizard');
             $conDat1 = $app->loadCon($isConID, $returnFields);
             if (isset($conDat1['_AttentionWizard']) && $conDat1['_AttentionWizard'] != 'Paid and Current' && $conDat1['_AttentionWizard'] != 'Free') {
                 $conDat['_AttentionWizard'] = 'Prepaid only - no subscription';
             }
             if (!isset($conDat1['_AttentionWizard'])) {
                 $conDat['_AttentionWizard'] = 'Prepaid only - no subscription';
             }
             $conID = $app->updateCon($isConID, $conDat);
             // Note is added
             $conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Purchased AW Prepaid Credits", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'UserID' => 1);
             $conActionID = $app->dsAdd("ContactAction", $conActionDat);
             // Update order
             $order->OrderStatus = 'c';
             $order->write();
             // Create a Subscription record
             $subscription = new Subscription();
             $subscription->StartDate = date("Y-m-d H:i:s");
             $subscription->MemberID = $member->ID;
             $subscription->ProductID = $data['ProductID'];
             $subscription->OrderID = $orderID;
             $subscription->write();
             // Create a MemberCredits record
             $memberCredits = new MemberCredits();
             $memberCredits->Credits = $product->Credits * $data['Quantity'];
             $memberCredits->MemberID = $member->ID;
             $memberCredits->ProductID = $product->ID;
             $memberCredits->SubscriptionID = $subscription->ID;
             $memberCredits->write();
             $form->sessionMessage("Purchased non-expiring heatmaps successfully.", 'good');
             return Controller::curr()->redirect("admin/manage-data/Subscription/EditForm/field/Subscription/item/{$subscription->ID}/edit");
         } else {
             // Add an AW prospect tag
             $app->grpAssign($isConID, $Page_Ctrl->getISTagIdByPaymentCode(strtoupper($result['Code'])));
             // Add a note
             $conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Unsuccessful attempt to purchase prepaid plan", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'UserID' => 1);
             $conActionID = $app->dsAdd("ContactAction", $conActionDat);
             $form->sessionMessage("Sorry,the payment failed,please update the user credit card.", 'bad');
             return $this->edit(Controller::curr()->getRequest());
         }
     }
     //Process subscriptions
     if ($productId == 1 || $productId == 2 || $productId == 3) {
         $credits = $product->Credits;
         $subscriptionID = $Page_Ctrl->createISSubscription($isConID, $product->ISProductID, $product->RecurringPrice, $ccID, 30);
         if ($subscriptionID && is_int($subscriptionID)) {
             if ($productId == 1 && !$Page_Ctrl->isCCUsedForTrial($creditCard->CreditCardNumber)) {
//.........这里部分代码省略.........
开发者ID:hemant-chakka,项目名称:awss,代码行数:101,代码来源:DataAdmin.php


注:本文中的Page_Controller::getNonExpiringIsProductId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。