コード例 #1
0
ファイル: Cart66Admin.php プロジェクト: rbredow/allyzabbacart
 public static function paypalSubscriptions()
 {
     $data = array();
     if (CART66_PRO) {
         $sub = new Cart66PayPalSubscription();
         $data['subscription'] = $sub;
         if ($_SERVER['REQUEST_METHOD'] == 'POST' && Cart66Common::postVal('cart66-action') == 'save paypal subscription') {
             $subData = Cart66Common::postVal('subscription');
             $subData['setup_fee'] = isset($subData['setup_fee']) ? Cart66Common::convert_currency_to_number($subData['setup_fee']) : '';
             $subData['price'] = isset($subData['price']) ? Cart66Common::convert_currency_to_number($subData['price']) : '';
             $sub->setData($subData);
             $errors = $sub->validate();
             if (count($errors) == 0) {
                 $sub->save();
                 $sub->clear();
                 $data['subscription'] = $sub;
             } else {
                 $data['errors'] = $sub->getErrors();
                 $data['jqErrors'] = $sub->getJqErrors();
             }
         } else {
             if (Cart66Common::getVal('task') == 'edit' && isset($_GET['id'])) {
                 $sub->load(Cart66Common::getVal('id'));
                 $data['subscription'] = $sub;
             } elseif (Cart66Common::getVal('task') == 'delete' && isset($_GET['id'])) {
                 $sub->load(Cart66Common::getVal('id'));
                 $sub->deleteMe();
                 $sub->clear();
                 $data['subscription'] = $sub;
             }
         }
         $data['plans'] = $sub->getModels('where is_paypal_subscription>0', 'order by name', '1');
         $view = Cart66Common::getView('pro/admin/paypal-subscriptions.php', $data);
         echo $view;
     } else {
         echo '<h2>PayPal Subscriptions</h2><p class="description">This feature is only available in <a href="http://cart66.com">Cart66 Professional</a>.</p>';
     }
 }
コード例 #2
0
<?php

$product = new Cart66Product();
$adminUrl = get_bloginfo('wpurl') . '/wp-admin/admin.php';
$errorMessage = false;
if ($_SERVER['REQUEST_METHOD'] == "POST" && $_POST['cart66-action'] == 'save product') {
    $_POST['product']['price'] = isset($_POST['product']['price']) ? Cart66Common::convert_currency_to_number($_POST['product']['price']) : '';
    try {
        $product->handleFileUpload();
        $product->setData(Cart66Common::postVal('product'));
        $product->save();
        $product->clear();
    } catch (Cart66Exception $e) {
        $errorCode = $e->getCode();
        if ($errorCode == 66102) {
            // Product save failed
            $errors = $product->getErrors();
            $errorMessage = Cart66Common::showErrors($errors, "<p><b>" . __("The product could not be saved for the following reasons", "cart66") . ":</b></p>");
        } elseif ($errorCode == 66101) {
            // File upload failed
            $errors = $product->getErrors();
            $errorMessage = Cart66Common::showErrors($errors, "<p><b>" . __("The file upload failed", "cart66") . ":</b></p>");
        }
        Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Product save failed ({$errorCode}): " . strip_tags($errorMessage));
    }
} elseif (isset($_GET['task']) && $_GET['task'] == 'edit' && isset($_GET['id']) && $_GET['id'] > 0) {
    $id = Cart66Common::getVal('id');
    $product->load($id);
} elseif (isset($_GET['task']) && $_GET['task'] == 'delete' && isset($_GET['id']) && $_GET['id'] > 0) {
    $id = Cart66Common::getVal('id');
    $product->load($id);
コード例 #3
0
<?php

$promo = new Cart66Promotion();
$errorMessage = false;
if ($_SERVER['REQUEST_METHOD'] == "POST" && $_POST['cart66-action'] == 'save promotion') {
    $_POST['promo']['amount'] = isset($_POST['promo']['amount']) ? Cart66Common::convert_currency_to_number($_POST['promo']['amount']) : '';
    $_POST['promo']['min_order'] = isset($_POST['promo']['min_order']) ? Cart66Common::convert_currency_to_number($_POST['promo']['min_order']) : '';
    $_POST['promo']['max_order'] = isset($_POST['promo']['max_order']) ? Cart66Common::convert_currency_to_number($_POST['promo']['max_order']) : '';
    try {
        $promo->load($_POST['promo']['id']);
        $promo->setData($_POST['promo']);
        $promo->save();
        $promo->clear();
    } catch (Cart66Exception $e) {
        $errorCode = $e->getCode();
        if ($errorCode == 66301) {
            // Promotion save failed
            $errors = $promo->getErrors();
            $errorMessage = Cart66Common::showErrors($errors, "<p><b>" . __("The promotion could not be saved for the following reasons", "cart66") . ":</b></p>");
        }
        Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Promotion save failed ({$errorCode}): " . strip_tags($errorMessage));
    }
} elseif (isset($_GET['task']) && $_GET['task'] == 'edit' && isset($_GET['id']) && $_GET['id'] > 0) {
    $id = Cart66Common::getVal('id');
    $promo->load($id);
} elseif (isset($_GET['task']) && $_GET['task'] == 'delete' && isset($_GET['id']) && $_GET['id'] > 0) {
    $id = Cart66Common::getVal('id');
    $promo->load($id);
    $promo->deleteMe();
    $promo->clear();
}