/** * Cart shortcode. * * Usage example: [wpsc-cart type="widget"] * * Available attributes: * - 'type': Can be set to 'form', 'widget', 'table'. * 'form' would display similarly to the Shopping Cart page * 'widget' would display similarly to the Cart widget * 'table' would display a plain table of items without form * * @param array $atts Attributes * @return string Shortcode output */ function _wpsc_shortcode_cart($atts) { global $wpsc_cart; ob_start(); $defaults = array('type' => 'form'); $atts = shortcode_atts($defaults, $atts, 'wpsc-cart'); require_once WPSC_TE_V2_CLASSES_PATH . '/cart-item-table-widget-form.php'; if (!count($wpsc_cart->cart_items)) { return '<p>' . __('No items in cart.', 'wp-e-commerce') . '</p>'; } switch ($atts['type']) { case 'form': $table = new WPSC_Cart_Item_Table_Form(); break; case 'widget': $table = new WPSC_Cart_Item_Table_Widget_Form(); break; case 'table': $table = new WPSC_Cart_Item_Table(); break; } $table->display(); return ob_get_clean(); }