diff --git a/fulcrm_shoppingcart.module b/fulcrm_shoppingcart.module index c0cdf3d..28c3f6b 100644 --- a/fulcrm_shoppingcart.module +++ b/fulcrm_shoppingcart.module @@ -97,13 +97,32 @@ function fulcrm_shoppingcart_get_session_cart( $create = true ) { function fulcrm_shoppingcart_buy( $product_id ) { $api_data = fulcrm_apiv2_GET( 'product/' . $product_id . '/', - $query = array( 'expand' => implode( ',', array( 'content_object', 'selector_object' ) ) ) ); - return print_r( $api_data, 1 ); + $query = array( 'expand' => implode( ',', array( 'content_object', + 'selector_object', + 'person_ddatacollection', + 'organisation_ddatacollection', + 'thing_ddatacollection', + 'transaction_ddatacollection', + 'lineitem_ddatacollection', + ) ) ) ); + + if ( $api_data[ 'success' ] ) { + switch ( fulcrm_apiv2_url_to_type( $api_data[ 'data' ][ 'content_object' ][ 'url' ] ) ) { + case 'eventbookingtype': + break; + default: + return 'cannot handle these products yet'; + } + + return 'ok!'; + } else { + return 'error adding item to shopping basket'; + } } function fulcrm_shoppingcart_cart() { $cart = fulcrm_shoppingcart_get_session_cart( false ); - return theme( 'fulcrm_shopping_cart', array( 'cart' => $cart ) ); + return theme( 'fulcrm_shoppingcart_cart', array( 'cart' => $cart ) ); } function fulcrm_shoppingcart_checkout() { diff --git a/fulcrm_shoppingcart_cart.tpl.php b/fulcrm_shoppingcart_cart.tpl.php index cc43cf5..f81ba93 100644 --- a/fulcrm_shoppingcart_cart.tpl.php +++ b/fulcrm_shoppingcart_cart.tpl.php @@ -1 +1,16 @@ -fulcrm_shoppingcart_cart.tpl.php + + + + + + + + + + + + + $cart[ 'shoppingitems' ] ) ); ?> + + +
Your shopping cart
ItemPriceQuantity
diff --git a/fulcrm_shoppingcart_item.tpl.php b/fulcrm_shoppingcart_item.tpl.php index 9461e94..b925394 100644 --- a/fulcrm_shoppingcart_item.tpl.php +++ b/fulcrm_shoppingcart_item.tpl.php @@ -1 +1,5 @@ - + + + + diff --git a/fulcrm_shoppingcart_items.tpl.php b/fulcrm_shoppingcart_items.tpl.php index 1df1d14..346bff5 100644 --- a/fulcrm_shoppingcart_items.tpl.php +++ b/fulcrm_shoppingcart_items.tpl.php @@ -1 +1,3 @@ - + $item ) ); ?> +