widget 250 gizmo 125 100 elements('widget')}) > 2 ) { return 0; } else { die; } ]]> 110 number_of('gizmo') > 10 ) { return $cost - 30; } else { die; } } ]]> #### service_agreement_3yr 150_000 100 customer()->last_ordered('widget'); if ( $widgets_order and $widgets_order->date() > time()-60*60*24*30 ) { return 100_000; } else { die; } } ]]> foo@bar.com 400 300 #---- item widget base_cost cost_hook apply_order code 'cost_hook' main items Read_only_file:'extension','.item' customer email cost_hook item:cost_hook 'cost_hook' num_orders read('order') ->get_index->('completed')->count ( where_clause => 'doc_id="' . $self->doc_id() . '"' ); ]]> last_ordered read('order') ->get_index->('orders')->single ( where_clause => 'doc_id="' . $self->doc_id() . '"', collection_spec => "items:$item", order_by => "timestamp DESC" ); ]]> main customers Sequential_dir main main email order customer_id timestamp total_paid item item_name item_quantity price_paid 'item' number_of item_quantity() if $_->item_name() eq $item; } $self->elements('item') ]]> make_totals read('customer|main|'.$self->customer_id()) || die "oops, couldn't get customer doc"; foreach my $i ( $self->elements('item') ) { my $this_total = $i->base_cost(); foreach $hook ( sort { $a->apply_order() <=> $b->apply_order() } ( $customer->elements('cost_hook'), $i->elements('cost_hook') ) ) { my $cost; eval { $this_total = $hook->code()->( $cart, $ ) }; return $cost unless $@; } my $extended = $this_total * $i->item_quantity(); $i->price_paid ( $extended ); $total += $extended; } $this->total_paid ( $total ); return $total; } ]]> carts carts Derived_file: 'derive_from','doc_id', 'extension','.order' orders orders Sequential_file orders orders customer_id timestamp total_paid items item_name() } $_[0]->item() }; ]]>