add some support for customizing product options
[bse.git] / site / cgi-bin / modules / BSE / UI / Shop.pm
index e03e7dd..5bfc98e 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.051";
+our $VERSION = "1.052";
 
 =head1 NAME
 
@@ -1125,6 +1125,7 @@ sub req_payment {
     $order_values->{paidFor} = 0;
     
     my @items = $class->_build_items($req);
+    my @cartitems = $cart->items;
     @products = $cart->products;
     
     if ($session->{order_work}) {
@@ -1183,7 +1184,7 @@ sub req_payment {
        my @option_descs = $product->option_descs($cfg, $item->{options});
        my $display_order = 1;
        for my $option (@option_descs) {
-         BSE::TB::OrderItemOptions->make
+         my $optionitem = BSE::TB::OrderItemOptions->make
              (
               order_item_id => $dbitem->{id},
               original_id => $option->{id},
@@ -1192,9 +1193,18 @@ sub req_payment {
               display => $option->{display},
               display_order => $display_order++,
              );
+         BSE::PubSub->customize(
+           order_item_option =>
+             {
+               cartitem => $cartitems[$row_num],
+               cartoption => $option->{valueobj},
+               cart => $cart,
+               orderitem => $dbitem,
+               orderitemoption => $optionitem,
+             });
        }
       }
-      
+
       my $sub = $product->subscription;
       if ($sub) {
        $subscribing_to{$sub->{text_id}} = $sub;
@@ -1815,7 +1825,13 @@ sub _build_items {
        $work{product_discount} = 0;
        $work{product_discount_units} = 0;
       }
-      
+      BSE::PubSub->customize(
+       order_build_item => {
+         cartitem => $item,
+         cart => $cart,
+         orderitem => \%work,
+        });
+
       push @newcart, \%work;
     }
   }