コード例 #1
0
ファイル: services.inc.php プロジェクト: NewRoute/paypal
/**
*   Allow a plugin to push an item into the cart
*
*   @param  array   $args   Array of item information
*   @param  mixed   &$output    Output data
*   @param  mixed   &$svc_msg   Service message
*   @return integer     Status code
*/
function service_addCartItem_paypal($args, &$output, &$svc_msg)
{
    global $ppGCart;
    USES_paypal_class_cart();
    $ppGCart = new ppCart();
    $qty = isset($args['quantity']) ? (double) $args['quantity'] : 1;
    if (!isset($args['item_number']) || empty($args['item_number'])) {
        return PLG_RET_ERROR;
    }
    $item_name = isset($args['item_name']) ? $args['item_name'] : '';
    $amount = isset($args['amount']) ? (double) $args['amount'] : 0;
    $descrip = isset($args['short_description']) ? $args['short_description'] : '';
    $options = isset($args['options']) ? $args['options'] : array();
    $extras = isset($args['extras']) ? $args['extras'] : '';
    // Option to add an item only if it is not currently in the cart.
    // Cart::addItem will be called to increment the quantity if the
    // unique flag is not set.
    if (isset($args['unique']) && $args['unique']) {
        if ($ppGCart->Contains($args['item_number'])) {
            return PLG_RET_OK;
        }
    }
    $ppGCart->addItem($args['item_number'], $item_name, $descrip, $qty, $amount, $options, $extras);
    return PLG_RET_OK;
}
コード例 #2
0
ファイル: index.php プロジェクト: JohnToro/paypal
             }
             $view = $addr_type;
             break;
         } else {
             $_POST['useaddress'] = $addr_id[0];
         }
     }
     $view = ppWorkflow::getNextView($addr_type);
     $ppGCart->setAddress($_POST, $addr_type);
     break;
 case 'addcartitem':
 case 'addcartitem_x':
     // using the image submit button, such as Paypal's
     USES_paypal_class_cart();
     $view = 'productlist';
     if (isset($_POST['_unique']) && $_POST['_unique'] && $ppGCart->Contains($_POST['item_number']) !== false) {
         break;
     }
     $qty = isset($_POST['quantity']) ? (double) $_POST['quantity'] : 1;
     $ppGCart->addItem($_POST['item_number'], $_POST['item_name'], $_POST['item_descr'], $qty, $_POST['amount'], $_POST['options'], $_POST['extras']);
     if (isset($_POST['_ret_url'])) {
         COM_refresh($_POST['_ret_url']);
         exit;
     } elseif (PAYPAL_is_plugin_item(${$_POST}['item_number'])) {
         COM_refresh(PAYPAL_URL);
         exit;
     } else {
         COM_refresh(PAYPAL_URL . '/detail.php?id=' . $_POST['item_number']);
         exit;
     }
     break;