} {
- search_text
- {category_id:integer,notnull ""}
- usca_p:optional
-
+ search_text
+ {combocategory_id ""}
+ usca_p:optional
}
set user_id [ad_verify_and_get_user_id]
@@ -33,53 +33,74 @@
# want their offer price
# 4. Log this category_id, search_text into the user session
-ec_create_new_session_if_necessary [export_url_vars category_id search_text] cookies_are_not_required
-# type6
+# Decode the combo of category and subcategory ids
+if { ![empty_string_p $combocategory_id] } {
+ ns_log debug "BART: combocategory_id $combocategory_id"
+ set category_id [lindex [split $combocategory_id "|"] 0]
+ set subcategory_id [lindex [split $combocategory_id "|"] 1]
+} else {
+ set category_id ""
+ set subcategory_id ""
+}
+ec_create_new_session_if_necessary [export_url_vars category_id search_text] cookies_are_not_required
if { [string compare $user_session_id "0"] != 0 } {
db_dml insert_search_text_to_session_info "insert into ec_user_session_info (user_session_id, category_id, search_text) values (:user_session_id, :category_id, :search_text)"
}
-if { ![empty_string_p $category_id] } {
- set category_name [db_string get_category_name "select category_name from ec_categories where category_id=:category_id"]
+if { ![empty_string_p $subcategory_id] } {
+ set category_name "[ec_system_name] > [db_string get_subcategory_name "select category_name || ' > ' || subcategory_name from ec_categories c, ec_subcategories s where s.subcategory_id=:subcategory_id and c.category_id=s.category_id"] search results for '$search_text'"
} else {
- set category_name ""
+ if { ![empty_string_p $category_id] } {
+ set category_name "[ec_system_name] > [db_string get_category_name "select category_name from ec_categories where category_id=:category_id"] search results for '$search_text'"
+ } else {
+ set category_name "[ec_system_name] search results for '$search_text'"
+ }
}
-if { ![empty_string_p $category_id] } {
- set query_string "select p.product_name, p.product_id, p.dirname, p.one_line_description,pseudo_contains(p.product_name || p.one_line_description || p.detailed_description || p.search_keywords, :search_text) as score
- from ec_products_searchable p, ec_category_product_map c
- where c.category_id=:category_id
- and p.product_id=c.product_id
- and pseudo_contains(p.product_name || p.one_line_description || p.detailed_description || p.search_keywords, :search_text) > 0
- order by score desc"
+if { ![empty_string_p $subcategory_id] } {
+ set query_string [db_map search_subcategory]
+ # select p.product_name, p.product_id, p.dirname, p.one_line_description,pseudo_contains(p.product_name || p.one_line_description || p.detailed_description || p.search_keywords, :search_text) as score
+ # from ec_products_searchable p, ec_subcategory_product_map c
+ # where c.subcategory_id=:subcategory_id
+ # and p.product_id=c.product_id
+ # and pseudo_contains(p.product_name || p.one_line_description || p.detailed_description || p.search_keywords, :search_text) > 0
+ # order by score desc
} else {
- set query_string "select p.product_name, p.product_id, p.dirname, p.one_line_description,pseudo_contains(p.product_name || p.one_line_description || p.detailed_description || p.search_keywords, :search_text) as score
- from ec_products_searchable p
- where pseudo_contains(p.product_name || p.one_line_description || p.detailed_description || p.search_keywords, :search_text) > 0
- order by score desc"
+ if { ![empty_string_p $category_id] } {
+ set query_string [db_map search_category]
+ # select p.product_name, p.product_id, p.dirname, p.one_line_description,pseudo_contains(p.product_name || p.one_line_description || p.detailed_description || p.search_keywords, :search_text) as score
+ # from ec_products_searchable p, ec_category_product_map c
+ # where c.category_id=:category_id
+ # and p.product_id=c.product_id
+ # and pseudo_contains(p.product_name || p.one_line_description || p.detailed_description || p.search_keywords, :search_text) > 0
+ # order by score desc
+ } else {
+ set query_string [db_map search_all]
+ # select p.product_name, p.product_id, p.dirname, p.one_line_description,pseudo_contains(p.product_name || p.one_line_description || p.detailed_description || p.search_keywords, :search_text) as score
+ # from ec_products_searchable p
+ # where pseudo_contains(p.product_name || p.one_line_description || p.detailed_description || p.search_keywords, :search_text) > 0
+ # order by score desc
+ }
}
set search_string ""
set search_count 0
-
db_foreach get_product_listing_from_search $query_string {
-
incr search_count
-
- append search_string "
-
-
-
- $product_name |
- $one_line_description |
- [ec_price_line $product_id $user_id ""] |
-
- |
-[ec_linked_thumbnail_if_it_exists $dirname "t" "t"] |
-
-
-"
+ append search_string "
+
+
+
+
+ $product_name |
+ $one_line_description |
+ [ec_price_line $product_id $user_id ""] |
+
+ |
+ [ec_linked_thumbnail_if_it_exists $dirname "t" "t"] |
+
+
"
}
if { $search_count == 0 } {
Index: openacs-4/packages/ecommerce/www/product-search.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/product-search.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/product-search.xql 10 Jul 2001 20:42:02 -0000 1.1
+++ openacs-4/packages/ecommerce/www/product-search.xql 16 Feb 2002 23:32:06 -0000 1.2
@@ -1,18 +1,22 @@
-
-
+
+
insert into ec_user_session_info (user_session_id, category_id, search_text) values (:user_session_id, :category_id, :search_text)
-
-
+
+
-
-
-
+
+
select category_name from ec_categories where category_id=:category_id
-
-
+
+
-
+
+
+ select category_name || ' > ' || subcategory_name from ec_categories c, ec_subcategories s where s.subcategory_id=:subcategory_id and c.category_id=s.category_id
+
+
+
Index: openacs-4/packages/ecommerce/www/select-shipping.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/select-shipping.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/ecommerce/www/select-shipping.tcl 16 Feb 2002 23:32:06 -0000 1.1
@@ -0,0 +1,128 @@
+# /www/ecommerce/checkout-2.tcl
+ad_page_contract {
+ @param address_id a stored address
+ @param tax_exempt_p a flag to indicate if the customer is tax exempt
+ @param usca_p User session started or not
+
+ @author
+ @creation-date
+ @cvs-id checkout-2.tcl,v 3.7.2.13 2000/08/18 21:46:32 stevenp Exp
+ @author ported by Jerry Asher (jerry@theashergroup.com)
+} {
+ address_id:optional,naturalnum
+ tax_exempt_p:optional
+ usca_p:optional
+}
+
+# ec_redirect_to_https_if_possible_and_necessary
+# we need them to be logged in
+set user_id [ad_verify_and_get_user_id]
+if {$user_id == 0} {
+ set return_url "[ad_conn url]"
+ ad_returnredirect "/register?[export_url_vars return_url]"
+ return
+}
+
+# user sessions:
+# 1. get user_session_id from cookie
+# 2. if user has no session (i.e. user_session_id=0), attempt to set it if it hasn't been
+# attempted before
+# 3. if it has been attempted before, give them message that we can't do shopping carts
+# without cookies
+set user_session_id [ec_get_user_session_id]
+ec_create_new_session_if_necessary [export_url_vars address_id]
+
+# make sure they have an in_basket order, otherwise they've probably
+# gotten here by pushing Back, so return them to index.tcl
+set success_p [db_0or1row get_order_id_and_order_owner " select order_id, user_id as order_owner from ec_orders where user_session_id=:user_session_id and order_state='in_basket' "]
+if { ! $success_p } {
+ # No rows came back, so they probably got here by pushing "Back", so just redirect them
+ # to index.tcl
+ ad_returnredirect [ec_url]index.tcl
+ return
+}
+
+if { $order_owner != $user_id } {
+ # make sure the order belongs to this user_id (why? because before this point there was no
+ # personal information associated with the order (so it was fine to go by user_session_id),
+ # but now there is, and we don't want someone messing with their user_session_id cookie and
+ # getting someone else's order)
+
+ # if they get here, either they managed to skip past checkout.tcl, or they messed
+ # w/their user_session_id cookie;
+ ad_returnredirect [ec_securelink [ec_url]checkout.tcl]
+ return
+}
+
+# make sure there's something in their shopping cart, otherwise
+# redirect them to their shopping cart which will tell them
+# that it's empty.
+if { [db_string get_ec_item_count "select count(*) from ec_items where order_id=:order_id"] == 0 } {
+ ad_returnredirect [ec_url]shopping-cart
+ return
+}
+
+# either address_id should be a form variable, or it should already
+# be in the database for this order
+
+# make sure address_id, if it exists, belongs to them, otherwise
+# they've probably gotten here by form surgery, in which case send
+# them back to checkout.tcl
+# if it is theirs, put it into the database for this order
+
+# if address_id doesn't exist, make sure there is an address for this order,
+# otherwise they've probably gotten here via url surgery, so redirect them
+# to checkout.tcl
+if { [info exists address_id] && ![empty_string_p $address_id] } {
+ set n_this_address_id_for_this_user [db_string get_an_address_id "select count(*) from ec_addresses where address_id=:address_id and user_id=:user_id"]
+ if {$n_this_address_id_for_this_user == 0} {
+ ad_returnredirect [ec_securelink [ec_url]checkout]
+ return
+ }
+ # it checks out ok
+ db_dml update_ec_order_address "update ec_orders set shipping_address=:address_id where order_id=:order_id"
+} else {
+ set address_id [db_string get_address_id "select shipping_address from ec_orders where order_id=:order_id" -default ""]
+ if { [empty_string_p $address_id] } {
+ ad_returnredirect [ec_securelink [ec_url]checkout]
+ return
+ }
+}
+
+# everything is ok now; the user has a non-empty in_basket order and an
+# address associated with it, so now get the other necessary information
+
+set form_action [ec_securelink [ec_url]process-order-quantity-shipping]
+set shipping_avail_p [expr ![db_0or1row shipping_avail "select distinct p.no_shipping_avail_p from ec_items i, ec_products p where i.product_id = p.product_id and p.no_shipping_avail_p = 't' and i.order_id = :order_id"]]
+set shipping_options ""
+set checkout_step {Verify Order}
+if { [ad_parameter -package_id [ec_id] ExpressShippingP ecommerce] } {
+ if { $shipping_avail_p } {
+ set checkout_step {Select Shipping}
+ append shipping_options "
+ Shipping method:
+
+ Standard Shipping
+ Express
+ Pickup
+
+ "
+ } else {
+ set shipping_method "no shipping"
+ append shipping_options "
+ No Shipping Available:
+
+ [export_form_vars shipping_method]
+ One or more items in your order are not shippable.
+
+ "
+ }
+}
+
+# Export the tax exempt flag if one was passed on from checkout-2
+if {[info exists tax_exempt_p]} {
+ append shipping_options "[export_form_vars tax_exempt_p]"
+}
+
+db_release_unused_handles
+ec_return_template
Index: openacs-4/packages/ecommerce/www/select-shipping.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/select-shipping.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/ecommerce/www/select-shipping.xql 16 Feb 2002 23:32:06 -0000 1.1
@@ -0,0 +1,36 @@
+
+
+
+
+
+ select order_id, user_id as order_owner
+ from ec_orders
+ where user_session_id=:user_session_id and order_state='in_basket'
+
+
+
+
+
+ select count(*) from ec_addresses where address_id=:address_id and user_id=:user_id
+
+
+
+
+
+ update ec_orders set shipping_address=:address_id where order_id=:order_id
+
+
+
+
+
+ select shipping_address from ec_orders where order_id=:order_id
+
+
+
+
+
+ select distinct p.no_shipping_avail_p from ec_items i, ec_products p where i.product_id = p.product_id and p.no_shipping_avail_p = 't' and i.order_id = :order_id
+
+
+
+
Index: openacs-4/packages/ecommerce/www/shipping-address-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/Attic/shipping-address-2.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/ecommerce/www/shipping-address-2.tcl 29 Jan 2002 00:11:46 -0000 1.3
+++ openacs-4/packages/ecommerce/www/shipping-address-2.tcl 16 Feb 2002 23:32:06 -0000 1.4
@@ -1,18 +1,21 @@
# www/ecommerce/shipping-address-2.tcl
ad_page_contract {
- @param attn
+ @param address_id:optional
+ @param attn
@param line1
@param line2:optional
@param city
@param usps_abbrev
@param zip_code
@param phone
@param phone_time:optional
- @author
- @creation-date
- @cvs-id shipping-address-2.tcl,v 3.2.6.7 2000/08/18 21:46:35 stevenp Exp
- @author ported by Jerry Asher (jerry@theashergroup.com)
+ @author
+ @creation-date
+ @cvs-id shipping-address-2.tcl,v 3.2.6.7 2000/08/18 21:46:35 stevenp Exp
+ @author ported by Jerry Asher (jerry@theashergroup.com)
+ @author Bart Teeuwisse
} {
+ address_id:optional
attn
line1
line2:optional
@@ -23,9 +26,7 @@
phone_time:optional
}
-
set possible_exception_list [list [list attn name] [list line1 address] [list city city] [list usps_abbrev state] [list zip_code "zip code"] [list phone "telephone number"]]
-
set exception_count 0
set exception_text ""
@@ -43,57 +44,45 @@
# we need them to be logged in
set user_id [ad_verify_and_get_user_id]
-
if {$user_id == 0} {
-
set return_url "[ad_conn url]?[export_entire_form_as_url_vars]"
-
ad_returnredirect "/register?[export_url_vars return_url]"
return
}
# make sure they have an in_basket order, otherwise they've probably
# gotten here by pushing Back, so return them to index.tcl
-
set user_session_id [ec_get_user_session_id]
-
-
-
set order_id [db_string get_order_id "select order_id from ec_orders where user_session_id=:user_session_id and order_state='in_basket'" -default ""]
-
if { [empty_string_p $order_id] } {
- # then they probably got here by pushing "Back", so just redirect them
- # to index.tcl
+ # then they probably got here by pushing "Back", so just redirect them to index.tcl
ad_returnredirect index.tcl
return
}
-set address_id [db_nextval ec_address_id_sequence]
-
-db_transaction {
-
- db_dml insert_new_address "insert into ec_addresses
- (address_id, user_id, address_type, attn, line1, line2, city, usps_abbrev, zip_code, country_code, phone, phone_time)
- values
- (:address_id, :user_id, 'shipping', :attn, :line1,:line2,:city,:usps_abbrev,:zip_code,'US',:phone,:phone_time)
- "
-
- db_dml set_shipping_on_order "update ec_orders set shipping_address=:address_id where order_id=:order_id"
-
-}
-db_release_unused_handles
-
-# array set drivers [ec_preferred_drivers]
-# if { [ad_ssl_available_p] } {
-# set ssl_port [ns_config -int "ns/server/[ns_info server]/module/$drivers(sdriver)" Port 443]
-# if { $ssl_port == 443 } {
-# set ssl_port ""
-# } else {
-# set ssl_port ":$ssl_port"
-# }
-# ad_returnredirect "https://[ns_config ns/server/[ns_info server]/module/$drivers(sdriver) Hostname]${ssl_port}[ec_url]checkout-2"
-# } else {
-# ad_returnredirect "http://[ns_config ns/server/[ns_info server]/module/$drivers(driver) Hostname][ec_url]checkout-2"
-# }
-
-ad_returnredirect [ec_securelink [ec_url]checkout-2]
+if { [info exists address_id] } {
+ # This is an existing address that has been edited.
+ db_transaction {
+ db_dml update_address "update ec_addresses
+ set attn=:attn, line1=:line1, line2=:line2, city=:city, usps_abbrev=:usps_abbrev, zip_code=:zip_code, phone=:phone, phone_time=:phone_time
+ where address_id=:address_id"
+ db_dml set_shipping_on_order "update ec_orders set shipping_address=:address_id where order_id=:order_id"
+ }
+ db_release_unused_handles
+ # The user updated the address, return to the first step in checkout process
+ # where the user can opt to use this modified address.
+ ad_returnredirect [ec_securelink [ec_url]checkout]
+} else {
+ # This is a new address which requires an address_id.
+ set address_id [db_nextval ec_address_id_sequence]
+ db_transaction {
+ db_dml insert_new_address "insert into ec_addresses
+ (address_id, user_id, address_type, attn, line1, line2, city, usps_abbrev, zip_code, country_code, phone, phone_time)
+ values
+ (:address_id, :user_id, 'shipping', :attn, :line1,:line2,:city,:usps_abbrev,:zip_code,'US',:phone,:phone_time)"
+ db_dml set_shipping_on_order "update ec_orders set shipping_address=:address_id where order_id=:order_id"
+ }
+ db_release_unused_handles
+ # Continue with the next step in the checkout process.
+ ad_returnredirect [ec_securelink [ec_url]checkout-2]
+}
\ No newline at end of file
Index: openacs-4/packages/ecommerce/www/shipping-address-2.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/Attic/shipping-address-2.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/ecommerce/www/shipping-address-2.xql 22 Oct 2001 07:38:06 -0000 1.2
+++ openacs-4/packages/ecommerce/www/shipping-address-2.xql 16 Feb 2002 23:32:06 -0000 1.3
@@ -1,29 +1,33 @@
-
-
+
+
select order_id from ec_orders where user_session_id=:user_session_id and order_state='in_basket'
-
-
-
+
+
-
-
- insert into ec_addresses
- (address_id, user_id, address_type, attn, line1, line2, city, usps_abbrev, zip_code, country_code, phone, phone_time)
- values
- (:address_id, :user_id, 'shipping', :attn, :line1,:line2,:city,:usps_abbrev,:zip_code,'US',:phone,:phone_time)
-
-
-
+
+
+ update ec_addresses
+ set attn=:attn, line1=:line1, line2=:line2, city=:city, usps_abbrev=:usps_abbrev, zip_code=:zip_code, phone=:phone, phone_time=:phone_time
+ where address_id=:address_id
+
+
+
+
+ insert into ec_addresses
+ (address_id, user_id, address_type, attn, line1, line2, city, usps_abbrev, zip_code, country_code, phone, phone_time)
+ values
+ (:address_id, :user_id, 'shipping', :attn, :line1,:line2,:city,:usps_abbrev,:zip_code,'US',:phone,:phone_time)
+
+
-
-
- update ec_orders set shipping_address=:address_id where order_id=:order_id
-
-
-
+
+
+ update ec_orders set shipping_address=:address_id where order_id=:order_id
+
+
Index: openacs-4/packages/ecommerce/www/shipping-address.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/Attic/shipping-address.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/ecommerce/www/shipping-address.tcl 23 Oct 2001 05:07:14 -0000 1.3
+++ openacs-4/packages/ecommerce/www/shipping-address.tcl 16 Feb 2002 23:32:06 -0000 1.4
@@ -1,42 +1,47 @@
# www/ecommerce/shipping-address.tcl
ad_page_contract {
@param usca_p:optional
- @author
- @creation-date
- @cvs-id shipping-address.tcl,v 3.1.6.5 2000/08/18 21:46:35 stevenp Exp
- @author ported by Jerry Asher (jerry@theashergroup.com)
+ @param address_id:optional
+ @author
+ @creation-date
+ @cvs-id shipping-address.tcl,v 3.1.6.5 2000/08/18 21:46:35 stevenp Exp
+ @author ported by Jerry Asher (jerry@theashergroup.com)
+ @author Bart Teeuwisse
} {
usca_p:optional
+ address_id:optional
}
-
-
# we need them to be logged in
set user_id [ad_verify_and_get_user_id]
if {$user_id == 0} {
-
set return_url "[ad_conn url]"
-
ad_returnredirect "/register?[export_url_vars return_url]"
return
}
# user session tracking
set user_session_id [ec_get_user_session_id]
-
ec_create_new_session_if_necessary
-# type1
-
ec_log_user_as_user_id_for_this_session
-set user_name_with_quotes_escaped [ad_quotehtml [db_string get_full_name "select first_names || ' ' || last_name as name from cc_users where user_id=:user_id"]]
-db_release_unused_handles
-set state_widget [state_widget]
+# Retrieve the default name of the person to ship to.
+set attn [db_string get_full_name "select first_names || ' ' || last_name as name from cc_users where user_id=:user_id"]
-ec_return_template
+# Retrieve the saved address with address_id.
+if { [info exists address_id] } {
+ db_0or1row shipping_address "select attn, line1, line2, city, usps_abbrev, zip_code, phone, country_code, full_state_name, phone_time from ec_addresses where address_id=:address_id"
+}
+set user_name_with_quotes_escaped [ad_quotehtml $attn]
+db_release_unused_handles
+if { [info exists usps_abbrev] } {
+ set state_widget [state_widget $usps_abbrev]
+} else {
+ set state_widget [state_widget]
+}
-
+ec_return_template
\ No newline at end of file
Index: openacs-4/packages/ecommerce/www/shipping-address.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/Attic/shipping-address.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/shipping-address.xql 10 Jul 2001 20:42:02 -0000 1.1
+++ openacs-4/packages/ecommerce/www/shipping-address.xql 16 Feb 2002 23:32:06 -0000 1.2
@@ -1,11 +1,16 @@
-
-
- select first_names || ' ' || last_name as name from cc_users where user_id=:user_id
-
-
-
+
+
+ select first_names || ' ' || last_name as name from cc_users where user_id=:user_id
+
+
+
+
+ select attn, line1, line2, city, usps_abbrev, zip_code, phone, country_code, full_state_name, phone_time from ec_addresses where address_id=:address_id
+
+
+
Index: openacs-4/packages/ecommerce/www/shopping-cart-add-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/shopping-cart-add-oracle.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/ecommerce/www/shopping-cart-add-oracle.xql 29 Jan 2002 00:11:46 -0000 1.2
+++ openacs-4/packages/ecommerce/www/shopping-cart-add-oracle.xql 16 Feb 2002 23:32:06 -0000 1.3
@@ -1,36 +1,33 @@
- oracle8.1.6
+ oracle8.1.6
-
-
+
+
insert into ec_orders
- (order_id, user_session_id, order_state, in_basket_date)
- select :order_id, :user_session_id, 'in_basket', sysdate from dual
- where not exists (select 1 from ec_orders where user_session_id=:user_session_id and order_state='in_basket')
-
-
-
+ (order_id, user_session_id, order_state, in_basket_date)
+ select :order_id, :user_session_id, 'in_basket', sysdate from dual
+ where not exists (select 1 from ec_orders where user_session_id=:user_session_id and order_state='in_basket')
+
+
-
-
+
+
insert into ec_problems_log
- (problem_id, problem_date, problem_details)
- values
- (ec_problem_id_sequence.nextval, sysdate,:errormsg)
-
-
-
+ (problem_id, problem_date, problem_details)
+ values
+ (ec_problem_id_sequence.nextval, sysdate,:errormsg)
+
+
-
-
+
+
insert into ec_items
-(item_id, product_id, color_choice, size_choice, style_choice, order_id, in_cart_date)
-(select ec_item_id_sequence.nextval, :product_id, :color_choice, :size_choice, :style_choice, :order_id, sysdate from dual
- where not exists (select 1 from ec_items where order_id=:order_id and product_id=:product_id and color_choice [ec_decode $color_choice "" "is null" "= :color_choice"] and size_choice [ec_decode $size_choice "" "is null" "= :size_choice"] and style_choice [ec_decode $style_choice "" "is null" "= :style_choice"]))
-
-
-
+ (item_id, product_id, color_choice, size_choice, style_choice, order_id, in_cart_date)
+ (select ec_item_id_sequence.nextval, :product_id, :color_choice, :size_choice, :style_choice, :order_id, sysdate from dual
+ where not exists (select 1 from ec_items where order_id=:order_id and product_id=:product_id and color_choice [ec_decode $color_choice "" "is null" "= :color_choice"] and size_choice [ec_decode $size_choice "" "is null" "= :size_choice"] and style_choice [ec_decode $style_choice "" "is null" "= :style_choice"] and ((sysdate() - in_cart_date) * 86400 < 5)))
+
+
Index: openacs-4/packages/ecommerce/www/shopping-cart-add-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/shopping-cart-add-postgresql.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/ecommerce/www/shopping-cart-add-postgresql.xql 29 Jan 2002 00:11:46 -0000 1.2
+++ openacs-4/packages/ecommerce/www/shopping-cart-add-postgresql.xql 16 Feb 2002 23:32:06 -0000 1.3
@@ -1,36 +1,33 @@
- postgresql7.1
+ postgresql7.1
-
-
+
+
insert into ec_orders
- (order_id, user_session_id, order_state, in_basket_date)
- select :order_id, :user_session_id, 'in_basket', current_timestamp
- where not exists (select 1 from ec_orders where user_session_id=:user_session_id and order_state='in_basket')
-
-
-
+ (order_id, user_session_id, order_state, in_basket_date)
+ select :order_id, :user_session_id, 'in_basket', current_timestamp
+ where not exists (select 1 from ec_orders where user_session_id=:user_session_id and order_state='in_basket')
+
+
-
-
+
+
insert into ec_problems_log
- (problem_id, problem_date, problem_details)
- values
- (ec_problem_id_sequence.nextval, current_timestamp,:errormsg)
-
-
-
+ (problem_id, problem_date, problem_details)
+ values
+ (ec_problem_id_sequence.nextval, current_timestamp,:errormsg)
+
+
-
-
+
+
insert into ec_items
-(item_id, product_id, color_choice, size_choice, style_choice, order_id, in_cart_date)
-(select ec_item_id_sequence.nextval, :product_id, :color_choice, :size_choice, :style_choice, :order_id, current_timestamp
- where not exists (select 1 from ec_items where order_id=:order_id and product_id=:product_id and color_choice [ec_decode $color_choice "" "is null" "= :color_choice"] and size_choice [ec_decode $size_choice "" "is null" "= :size_choice"] and style_choice [ec_decode $style_choice "" "is null" "= :style_choice"]))
-
-
-
+ (item_id, product_id, color_choice, size_choice, style_choice, order_id, in_cart_date)
+ (select ec_item_id_sequence.nextval, :product_id, :color_choice, :size_choice, :style_choice, :order_id, current_timestamp
+ where not exists (select 1 from ec_items where order_id=:order_id and product_id=:product_id and color_choice [ec_decode $color_choice "" "is null" "= :color_choice"] and size_choice [ec_decode $size_choice "" "is null" "= :size_choice"] and style_choice [ec_decode $style_choice "" "is null" "= :style_choice"] and (date_part('epoch', now()) - date_part('epoch', in_cart_date) < 5)))
+
+
Index: openacs-4/packages/ecommerce/www/shopping-cart-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/shopping-cart-add.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/ecommerce/www/shopping-cart-add.tcl 29 Jan 2002 00:11:46 -0000 1.2
+++ openacs-4/packages/ecommerce/www/shopping-cart-add.tcl 16 Feb 2002 23:32:06 -0000 1.3
@@ -1,23 +1,26 @@
# www/ecommerce/shopping-cart-add.tcl
ad_page_contract {
- This adds an item to an 'in_basket' order, although if there exists a 'confirmed'
- order for this user_session_id, the user is told they have to wait because
- 'confirmed' orders can potentially become 'in_basket' orders (if authorization
- fails), and we can only have one 'in_basket' order for this user_session_id at
- a time. Most orders are only in the 'confirmed' state for a few seconds, except
- for those whose credit card authorizations are inconclusive. Furthermore, it is
- unlikely for a user to start adding things to their shopping cart right after they've
- made an order. So this case is unlikely to occur often. I will include a ns_log Notice so that any occurrences will be logged.
+ This adds an item to an 'in_basket' order, although if there
+ exists a 'confirmed' order for this user_session_id, the user is
+ told they have to wait because 'confirmed' orders can potentially
+ become 'in_basket' orders (if authorization fails), and we can
+ only have one 'in_basket' order for this user_session_id at a
+ time. Most orders are only in the 'confirmed' state for a few
+ seconds, except for those whose credit card authorizations are
+ inconclusive. Furthermore, it is unlikely for a user to start
+ adding things to their shopping cart right after they've made an
+ order. So this case is unlikely to occur often. I will include a
+ ns_log Notice so that any occurrences will be logged.
@param product_id:integer
@param size_choice
@param color_choice
@param style_choice
@param usca_p:optional
- @author
- @creation-date
- @cvs-id shopping-cart-add.tcl,v 3.3.2.6 2000/08/17 18:01:28 seb Exp
- @author ported by Jerry Asher (jerry@theashergroup.com)
+ @author
+ @creation-date
+ @cvs-id shopping-cart-add.tcl,v 3.3.2.6 2000/08/17 18:01:28 seb Exp
+ @author ported by Jerry Asher (jerry@theashergroup.com)
} {
product_id:integer
size_choice
@@ -26,9 +29,6 @@
usca_p:optional
}
-
-
-
# 1. get user_session_id
# 1.5 see if there exists a 'confirmed' order for this user_session_id
# 2. get order_id
@@ -40,31 +40,15 @@
# 5. ad_returnredirect them to their shopping cart
set user_session_id [ec_get_user_session_id]
-
ec_create_new_session_if_necessary [export_url_vars product_id]
-
set n_confirmed_orders [db_string get_n_confirmed_orders "select count(*) from ec_orders where user_session_id=:user_session_id and order_state='confirmed'"]
-
if { $n_confirmed_orders > 0 } {
ad_return_complaint 1 "Sorry, you have an order for which credit card authorization has not yet taken place. Please wait for the authorization to complete before adding new items to your shopping cart. Thank you."
return
}
set order_id [db_string get_order_id "select order_id from ec_orders where user_session_id=:user_session_id and order_state='in_basket'" -default ""]
-# This wasn't quite safe (e.g. if an in_basket order gets inserted between
-# the beginning of the if statement and the insert statement).
-
-# if { [empty_string_p $order_id] } {
-# set order_id [db_string get_new_order_id "select ec_order_id_sequence.nextval from dual"]
-# # create the order
-# db_dml insert_new_order "insert into ec_orders
-# (order_id, user_session_id, order_state, in_basket_date)
-# values
-# (:order_id, :user_session_id, 'in_basket', sysdate)
-# "
-# }
-
# Here's the airtight way to do it: do the check on order_id, then insert
# a new order where there doesn't exist an old one, then set order_id again
# (because the correct order_id might not be the one set inside the if
@@ -82,29 +66,31 @@
# now either an in_basket order should have been inserted by the above
# statement or it was inserted by a different thread milliseconds ago
set order_id [db_string get_order_id "select order_id from ec_orders where user_session_id=:user_session_id and order_state='in_basket'" -default ""]
-
if { [empty_string_p $order_id] } {
# I don't expect this to ever happen, but just in case, I'll log
# the problem and redirect them to product.tcl
- set errormsg "Null order_id on shopping-cart-add.tcl for user_session_id :user_session_id. Please report this problem to [ec_package_maintainer]."
-
+ set errormsg "Null order_id on shopping-cart-add.tcl for user_session_id :user_session_id. Please report this problem to [ec_package_maintainer]."
db_dml insert_problem_into_log "insert into ec_problems_log
- (problem_id, problem_date, problem_details)
- values
- (ec_problem_id_sequence.nextval, sysdate,:errormsg)"
+ (problem_id, problem_date, problem_details)
+ values
+ (ec_problem_id_sequence.nextval, sysdate,:errormsg)"
ad_returnredirect "product?[export_url_vars product_id]"
return
}
}
-# Insert an item into that order iff an identical item doesn't
+# Insert an item into that order if an identical item doesn't
# exist (this is double click protection).
# If they want to update quantities, they can do so from the
# shopping cart page.
+# Bart Teeuwisse: Fine tuned the postgresql version to only reject
+# items that were added to the shopping cart in the last 5 seconds.
+# That should be enough to protect from double clicks yet provides
+# a more intuitive user experience.
db_dml insert_new_item_in_order "insert into ec_items
-(item_id, product_id, color_choice, size_choice, style_choice, order_id, in_cart_date)
-(select ec_item_id_sequence.nextval, :product_id, :color_choice, :size_choice, :style_choice, :order_id, sysdate from dual
+ (item_id, product_id, color_choice, size_choice, style_choice, order_id, in_cart_date)
+ (select ec_item_id_sequence.nextval, :product_id, :color_choice, :size_choice, :style_choice, :order_id, sysdate from dual
where not exists (select 1 from ec_items where order_id=:order_id and product_id=:product_id and color_choice [ec_decode $color_choice "" "is null" "= :color_choice"] and size_choice [ec_decode $size_choice "" "is null" "= :size_choice"] and style_choice [ec_decode $style_choice "" "is null" "= :style_choice"]))"
db_release_unused_handles
-ad_returnredirect shopping-cart.tcl
+ad_returnredirect shopping-cart.tcl?[export_url_vars product_id]
Index: openacs-4/packages/ecommerce/www/shopping-cart.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/shopping-cart.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/shopping-cart.tcl 20 Apr 2001 20:51:13 -0000 1.1
+++ openacs-4/packages/ecommerce/www/shopping-cart.tcl 16 Feb 2002 23:32:07 -0000 1.2
@@ -8,9 +8,22 @@
@author ported by Jerry Asher (jerry@theashergroup.com)
} {
usca_p:optional
+ product_id:optional
}
+# bottom links:
+# 1) continue shopping (always)
+# Case 1) Continue shopping
+# Create the link now before the product_id gets overwritten when looping through the products
+# in the cart.
+if {[info exists product_id]} {
+ set bottom_links "Continue Shopping\n"
+} else {
+ set bottom_links "Continue Shopping\n"
+}
+
+
set cart_contents ""
# we don't need them to be logged in, but if they are they might get a lower price
@@ -33,6 +46,7 @@
and o.user_session_id=:user_session_id and o.order_state='in_basket'"]
set product_counter 0
+set total_price 0
db_foreach get_products_in_cart "select p.product_name, p.one_line_description, p.product_id, count(*) as quantity, u.offer_code, i.color_choice, i.size_choice, i.style_choice
from ec_orders o, ec_items i, ec_products p,
(select product_id, offer_code from ec_user_session_offer_codes usoc where usoc.user_session_id=:user_session_id) u
@@ -42,14 +56,23 @@
and o.user_session_id=:user_session_id and o.order_state='in_basket'
group by p.product_name, p.one_line_description, p.product_id, u.offer_code, i.color_choice, i.size_choice, i.style_choice" {
-
+ # No products listed yet, print header.
if { $product_counter == 0 } {
- append cart_contents "
"
} else {
- append cart_contents "Your Shopping Cart is empty.
+ # There are no products in the cart.
+ append cart_contents "
+ Your Shopping Cart is empty.
"
}
# bottom links:
-# 1) continue shopping (always)
+# 1) continue shopping (always and already created)
# 2) log in (if they're not logged in)
# 3) retrieve a saved cart (if they are logged in and they have a saved cart)
# 4) save their cart (if their cart is not empty)
-set bottom_links "Continue Shopping\n"
-
if { $user_id == 0 } {
- append bottom_links "Log In\n"
+ # Case 2) the user is not logged in.
+ append bottom_links "
+ "
} else {
- # see if they have any saved carts
- if { ![empty_string_p [db_string check_for_saved_carts "select 1 from dual where exists (select 1 from ec_orders where user_id=:user_id and order_state='in_basket' and saved_p='t')" -default ""]] } {
+ if { ![empty_string_p [db_string check_for_saved_carts "select 1 from dual where exists (select 1 from ec_orders where user_id=:user_id and order_state='in_basket' and saved_p='t')" -default ""]] } {
+ # Case 3) Retrieve saved carts
append bottom_links "Retrieve a Saved Cart\n"
}
}
if { $product_counter != 0 } {
+ # Case 4) Save non empty cart
append bottom_links "Save Your Cart for Later\n"
}
db_release_unused_handles
-ec_return_template
-
-
-
-
-
-
+ec_return_template
\ No newline at end of file
Index: openacs-4/packages/ecommerce/www/shopping-cart.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/shopping-cart.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/ecommerce/www/shopping-cart.xql 11 Jul 2001 04:52:05 -0000 1.2
+++ openacs-4/packages/ecommerce/www/shopping-cart.xql 16 Feb 2002 23:32:07 -0000 1.3
@@ -1,30 +1,34 @@
-
-
- select count(*) from
-ec_orders o, ec_items i
-where o.order_id=i.order_id
-and o.user_session_id=:user_session_id and o.order_state='in_basket'
-
-
-
+
+
+ select count(*)
+ from ec_orders o, ec_items i
+ where o.order_id=i.order_id
+ and o.user_session_id=:user_session_id and o.order_state='in_basket'
+
+
-
-
-
-select p.product_name, p.one_line_description, p.product_id, count(*) as quantity, u.offer_code, i.color_choice, i.size_choice, i.style_choice
-from ec_orders o
- JOIN ec_items i on (o.order_id=i.order_id)
- JOIN ec_products p on (i.product_id=p.product_id)
- LEFT JOIN (select product_id, offer_code from ec_user_session_offer_codes usoc where usoc.user_session_id=:user_session_id) u
- on (p.product_id=u.product_id)
-where o.user_session_id=:user_session_id and o.order_state='in_basket'
-group by p.product_name, p.one_line_description, p.product_id, u.offer_code, i.color_choice, i.size_choice, i.style_choice
-
-
-
-
+
+
+ select p.product_name, p.one_line_description, p.product_id, count(*) as quantity, u.offer_code, i.color_choice, i.size_choice, i.style_choice
+ from ec_orders o
+ JOIN ec_items i on (o.order_id=i.order_id)
+ JOIN ec_products p on (i.product_id=p.product_id)
+ LEFT JOIN (select product_id, offer_code from ec_user_session_offer_codes usoc where usoc.user_session_id=:user_session_id) u
+ on (p.product_id=u.product_id)
+ where o.user_session_id=:user_session_id and o.order_state='in_basket'
+ group by p.product_name, p.one_line_description, p.product_id, u.offer_code, i.color_choice, i.size_choice, i.style_choice
+
+
+
+
+ select tax_rate, initcap(state_name) as state
+ from ec_sales_tax_by_state tax, us_states state
+ where state.abbrev = tax.usps_abbrev
+
+
+
Index: openacs-4/packages/ecommerce/www/track.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/track.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/ecommerce/www/track.tcl 23 Oct 2001 05:48:48 -0000 1.3
+++ openacs-4/packages/ecommerce/www/track.tcl 16 Feb 2002 23:32:07 -0000 1.4
@@ -42,28 +42,25 @@
set carrier_info ""
if { $carrier == "FedEx" } {
- ### from Bart T.
set fedex_url "http://www.fedex.com/cgi-bin/tracking?tracknumbers=$tracking_number&action=track&language=english&cntry_code=us"
with_catch errmsg {
set page_from_fedex [ns_httpget $fedex_url]
- ### from Bart T.
- regexp {().*?()} $page_from_fedex match detailed_info scan_activity
+ regexp {().*?()} $page_from_fedex match detailed_info scan_activity
+ # Remove links
+ regsub -all -nocase {*?a.*?>} $scan_activity "" scan_activity
set carrier_info "$detailed_info $scan_activity"
} {
set carrier_info "Unable to retrieve data from FedEx."
}
} elseif { [string match "UPS*" $carrier] } {
- ### from Bart T.
set ups_url "http://wwwapps.ups.com/etracking/tracking.cgi?submit=Track&InquiryNumber1=$tracking_number&TypeOfInquiryNumber=T&build_detail=yes"
with_catch errmsg {
- ### from Bart T.
set ups_page [ns_httpget $ups_url]
- # UPS needs this magic line1 to get to the more interesting detail page.
- ### from Bart T.
if { ![regexp {(]*>Tracking Number:.* |
).*Tracking results provided by UPS} $ups_page match ups_info] } {
set carrier_info "Unable to parse detail data from UPS."
} else {
- ### from Bart T.
+ # Remove spacer images
+ regsub -all -nocase {} $ups_info "" ups_info
set carrier_info "$ups_info"
}
} {
Index: openacs-4/packages/ecommerce/www/admin/orders/track.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/orders/track.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/ecommerce/www/admin/orders/track.tcl 23 Oct 2001 05:56:16 -0000 1.2
+++ openacs-4/packages/ecommerce/www/admin/orders/track.tcl 16 Feb 2002 23:32:07 -0000 1.3
@@ -31,28 +31,25 @@
set carrier_info ""
if { $carrier == "FedEx" } {
- ### from Bart T.
set fedex_url "http://www.fedex.com/cgi-bin/tracking?tracknumbers=$tracking_number&action=track&language=english&cntry_code=us"
with_catch errmsg {
set page_from_fedex [ns_httpget $fedex_url]
- ### from Bart T.
- regexp {().*?()} $page_from_fedex match detailed_info scan_activity
+ regexp {().*?()} $page_from_fedex match detailed_info scan_activity
+ # Remove links
+ regsub -all -nocase {*?a.*?>} $scan_activity "" scan_activity
set carrier_info "$detailed_info $scan_activity"
} {
set carrier_info "Unable to retrieve data from FedEx."
}
} elseif { [string match "UPS*" $carrier] } {
- ### from Bart T.
set ups_url "http://wwwapps.ups.com/etracking/tracking.cgi?submit=Track&InquiryNumber1=$tracking_number&TypeOfInquiryNumber=T&build_detail=yes"
with_catch errmsg {
- ### from Bart T.
set ups_page [ns_httpget $ups_url]
- # UPS needs this magic line1 to get to the more interesting detail page.
- ### from Bart T.
if { ![regexp {(]*>Tracking Number:.* |
).*Tracking results provided by UPS} $ups_page match ups_info] } {
set carrier_info "Unable to parse detail data from UPS."
} else {
- ### from Bart T.
+ # Remove spacer images
+ regsub -all -nocase {} $ups_info "" ups_info
set carrier_info "$ups_info"
}
} {
Index: openacs-4/packages/ecommerce/www/admin/products/supporting-files-upload.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/products/supporting-files-upload.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/products/supporting-files-upload.tcl 20 Apr 2001 20:51:14 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/products/supporting-files-upload.tcl 16 Feb 2002 23:32:07 -0000 1.2
@@ -43,7 +43,7 @@
foreach file_name $file_list {
set file [lindex [file split $file_name] end]
- doc_body_append "$file \[delete]\n"
+ doc_body_append "$file \[delete]\n"
}
if { [string length $file_list] == 0 } {
Index: openacs-4/packages/ecommerce/www/templates/store/checkout-2.plain.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/templates/store/Attic/checkout-2.plain.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/templates/store/checkout-2.plain.adp 20 Apr 2001 20:51:14 -0000 1.1
+++ openacs-4/packages/ecommerce/www/templates/store/checkout-2.plain.adp 16 Feb 2002 23:32:07 -0000 1.2
@@ -1,6 +1,6 @@
Completing Your Order
-checkout $checkout_step
+checkout {$checkout_step}
Check Your Order
@@ -25,10 +25,6 @@
-<%= $shipping_options %>
-
-
-
<%= $tax_exempt_options %>
Index: openacs-4/packages/ecommerce/www/templates/store/checkout-3.plain.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/templates/store/Attic/checkout-3.plain.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/templates/store/checkout-3.plain.adp 20 Apr 2001 20:51:14 -0000 1.1
+++ openacs-4/packages/ecommerce/www/templates/store/checkout-3.plain.adp 16 Feb 2002 23:32:07 -0000 1.2
@@ -1,6 +1,6 @@
Please Confirm Your Order
-checkout confirm
+checkout {Confirm Order}
Please Confirm Your Order
Index: openacs-4/packages/ecommerce/www/templates/store/checkout.plain.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/templates/store/Attic/checkout.plain.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/templates/store/checkout.plain.adp 20 Apr 2001 20:51:14 -0000 1.1
+++ openacs-4/packages/ecommerce/www/templates/store/checkout.plain.adp 16 Feb 2002 23:32:07 -0000 1.2
@@ -1,5 +1,5 @@
Completing Your Order
-checkout welcome
+checkout {Select Address}
Completing Your Order
Index: openacs-4/packages/ecommerce/www/templates/store/payment.plain.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/templates/store/Attic/payment.plain.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/templates/store/payment.plain.adp 20 Apr 2001 20:51:14 -0000 1.1
+++ openacs-4/packages/ecommerce/www/templates/store/payment.plain.adp 16 Feb 2002 23:32:07 -0000 1.2
@@ -1,11 +1,15 @@
Payment Info
-checkout payment
+checkout {payment info}
Payment Info
+Your order will not be complete until you have confirmed the total in the next step.
+<% ns_puts [ad_parameter -package_id [ec_id] SystemName ecommerce] %> will not charge your card
+without your confirmation of the total.
+