Example #1
0
 function createTable()
 {
     $allCats = Module_EComm::getIndexes("ecomm_category", "id", "name", 0);
     $parentDropDown = array("0" => "- Top Level -");
     foreach ($allCats as $key => $val) {
         $parentDropDown[$key] = $val;
     }
     $cols = array('id?', DBColumn::make('!text', 'name', 'Name'), DBColumn::make('!select', 'parent_category', 'Parent Category', $parentDropDown), DBColumn::make('//integer', 'image', 'Image'), DBColumn::make('timestamp', 'date_added', 'Date Added'), DBColumn::make('//text', 'last_modified', 'Last Modified'), DBColumn::make('select', 'status', 'Status', array('1' => 'Active', '0' => 'Inactive')), DBColumn::make('tinymce', 'details', 'Details'));
     return new DBTable("ecomm_category", __CLASS__, $cols);
 }
Example #2
0
 public function doPayment()
 {
     //This method verifies that the user has paid for what has purchased.
     //First, make sure that the request came from Paypal
     //Second, make sure the payment status is "Completed", which means the funds have been added to the merchant's account.
     //Third, check the amount and currency
     $verifyIPN = $this->verifyIPNRequest();
     //Log the request, and then make sure it is from paypal
     $tid = @$_REQUEST["custom"];
     if (!$tid) {
         //There is no transaction ID here. EXIT
         return false;
     }
     $transaction = Transaction::getTransactionBasedOnTID($tid);
     if (!$verifyIPN) {
         $transaction->setStatus("Not verified, hacking attempt");
         $transaction->save();
         return false;
     }
     if (@$_REQUEST["payment_status"] != "Completed") {
         $transaction->setStatus("Status is: " . @$_REQUEST["payment_status"]);
         $transaction->save();
         return false;
     }
     $paymentVerification = Module_EComm::verifyPayment(@$_POST["mc_gross"], @$_POST["mc_currency"], $tid);
     if (!$paymentVerification[0]) {
         $st = "The user has not paid for what they ordered. Amont paid is: " . $paymentVerification[1] . " " . $paymentVerification[2];
         $st .= " Amount required is: " . $paymentVerification[3] . " " . $paymentVerification[4];
         $transaction->setStatus($st);
         $transaction->save();
         return false;
     }
     $transaction->setStatus("Complete");
     $transaction->save();
     return true;
 }
Example #3
0
 function createTable()
 {
     $cols = array('id?', DBColumn::make('!text', 'name', 'Title'), DBColumn::make('!select', 'supplier', 'Supplier', Module_EComm::getIndexes("ecomm_supplier", "id", "name", 0)), DBColumn::make('!select', 'category', 'Category', Module_EComm::getIndexes("ecomm_category", "id", "name", 0)), DBColumn::make('!select', 'producttype', 'Product Type', Module_EComm::getIndexes("ecomm_product_type", "id", "name", 0)), DBColumn::make('!select', 'tax_class', 'Tax Class', Module_EComm::getIndexes("ecomm_tax_class", "id", "name", 0)), DBColumn::make('!integer', 'stock_quantity', 'Stock Quantity'), DBColumn::make('//integer', 'image', 'Image'), DBColumn::make('!float', 'price', 'Price (' . SiteConfig::get("EComm::CurrencySign") . ")"), DBColumn::make('timestamp', 'date_added', 'Date Added'), DBColumn::make('//text', 'last_modified', 'Last Modified'), DBColumn::make('select', 'status', 'Status', array('1' => 'Active', '0' => 'Inactive')), DBColumn::make('tinymce', 'details', 'Details'));
     return new DBTable("ecomm_product", __CLASS__, $cols);
 }
Example #4
0
 public static function canUserCheckOut($session = null, $cartDetails = null)
 {
     /*
      * The criteria are:
      * 1. The user is logged in
      * 2. The user has shipping address
      * 3. The user has billing address
      * 4. The user has a phone number
      * 5. The order amount is more than a particular limit
      * 6. The shipping class is defined
      * 7. The payment class is defined
      */
     if (!$session) {
         $session = Session::getActiveSession();
     }
     $sessionId = $session->getId();
     if (!$session->getUser()) {
         //1. The user is logged in
         return "User is not logged in";
     }
     $userDetails = UserDetails::getUserDetailsBasedOnUserId($session->getUser());
     $shippingAddress = $userDetails->getAddress('shipping_address');
     if (!$shippingAddress || !$shippingAddress->getStreetAddress() || !$shippingAddress->getCity() || !$shippingAddress->getPostalCode() || !$shippingAddress->getState() || !$shippingAddress->getCountry()) {
         return "Shipping address cannot be empty";
     }
     $billingAddress = $userDetails->getAddress('billing_address');
     if (!$billingAddress || !$billingAddress->getStreetAddress() || !$billingAddress->getCity() || !$billingAddress->getPostalCode() || !$billingAddress->getState() || !$billingAddress->getCountry()) {
         return "Billing address cannot be empty";
     }
     if (!$userDetails->getPhoneNumber()) {
         //4.The user has a phone number
         return "Phone number cannot be empty";
     }
     if (!$cartDetails) {
         $cartDetails = Module_EComm::getCartDetails();
     }
     if ($cartDetails["subTotal"] < SiteConfig::get("EComm::MinimumOrderValue")) {
         //5. The order amount is more than a particular limit
         return "You must buy at least " . SiteConfig::get("EComm::MinimumOrderValue");
     }
     if (!$session->getShippingClass()) {
         //6. The shipping class is defined
         return "You did not select your shipping option";
     }
     if (!$session->getPaymentClass()) {
         //7. The payment class is defined
         return "You did not select your payment option";
     }
     return 0;
 }