allow purchase of products with missing options master optionprices
authorAdrian Oldham <adriann@visualthought.com.au>
Wed, 5 Aug 2020 10:59:24 +0000 (20:59 +1000)
committerTony Cook <tony@develop-help.com>
Fri, 14 Aug 2020 10:57:03 +0000 (20:57 +1000)
site/cgi-bin/modules/BSE/UI/Shop.pm
site/docs/config.pod

index 5bfc98e573e0f650a1117968a9f58a2ce3dea366..df6aeb92a083a3d915825ed36b6b6d1fa7bf35ac 100644 (file)
@@ -18,7 +18,7 @@ use BSE::Countries qw(bse_country_code);
 use BSE::Util::Secure qw(make_secret);
 use BSE::Template;
 
-our $VERSION = "1.052";
+our $VERSION = "1.053";
 
 =head1 NAME
 
@@ -1183,7 +1183,7 @@ sub req_payment {
        require BSE::TB::OrderItemOptions;
        my @option_descs = $product->option_descs($cfg, $item->{options});
        my $display_order = 1;
-       for my $option (@option_descs) {
+       for my $option (grep $_->{value} ne '', @option_descs) {
          my $optionitem = BSE::TB::OrderItemOptions->make
              (
               order_item_id => $dbitem->{id},
@@ -2044,14 +2044,20 @@ sub _validate_add {
   my @options;
   my @option_descs =  $product->option_descs($req->cfg);
   my @option_names = map $_->{name}, @option_descs;
+  my $allow_missing_options = $req->cfg->entry("shop", "allow_missing_options", 0);
   my @not_def;
   my $cgi = $req->cgi;
   for my $name (@option_names) {
     my $value = $cgi->param($name);
-    push @options, $value;
     unless (defined $value) {
-      push @not_def, $name;
+      if ($allow_missing_options) {
+       $value = "";
+      }
+      else {
+       push @not_def, $name;
+      }
     }
+    push @options, $value;
   }
   if (@not_def) {
     $$error = "Some product options (@not_def) not supplied";
index 591a50cb139c59f1a04e6b5ffff141345a57a545..b8b95d79daa98ccb72a0875d556718631bbccfaa 100644 (file)
@@ -1066,6 +1066,11 @@ If C<require_delivery> is true, and the C<need_delivery> CGI parameter
 is true, add the comma separated fields listed here to the required
 checkout fields list.  Default: none.
 
+=item allow_missing_options
+
+If true, products with missing options can be added to the cart and 
+purchased.  Default: false. 
+
 =back
 
 =head2 [shipping]