Example #1
0
 function widget($args, $options)
 {
     if (!empty($args)) {
         extract($args);
     }
     if (empty($options['title'])) {
         $options['title'] = __('Your Cart', 'Shopp');
     }
     $title = $before_title . $options['title'] . $after_title;
     if ('on' == $options['hide-empty'] && shopp_cart_items_count() == 0) {
         return;
     }
     $sidecart = shopp('cart', 'get-sidecart', $options);
     if (empty($sidecart)) {
         return;
     }
     echo $before_widget . $title . $sidecart . $after_widget;
 }
Example #2
0
/**
 * shopp_add_order - create an order from the cart and associate with a customer
 *
 * @api
 * @since 1.2
 *
 * @param int $customer the customer that the order will be created for
 * @return bool|ShoppPurchase false on failure, Purchase object of recently created order on success
 **/
function shopp_add_order($customer = false)
{
    // check customer
    if (!($Customer = shopp_customer((int) $customer))) {
        shopp_debug(__FUNCTION__ . " failed: Invalid customer.");
        return false;
    }
    if (!shopp_cart_items_count()) {
        shopp_debug(__FUNCTION__ . " failed: No items in cart.");
        return false;
    }
    $Order = ShoppOrder();
    $Order->Customer = $Customer;
    $Order->Billing = $Customer->Billing;
    $Order->Billing->cardtype = 'api';
    $Order->Shipping = $Customer->Shipping;
    shopp_add_order_event(false, 'purchase', array('gateway' => 'GatewayFramework'));
    shopp_empty_cart();
    return ($Purchase = ShoppPurchase()) ? $Purchase : false;
}