[interchange-docs] xmldocs - racke modified refs/CartTrigger
docs at icdevgroup.org
docs at icdevgroup.org
Wed Jul 18 07:57:34 EDT 2007
User: racke
Date: 2007-07-18 11:57:34 GMT
Modified: refs CartTrigger
Log:
replace generic example with instructive one from American Corners Support
Programm project
Revision Changes Path
1.5 +26 -4 xmldocs/refs/CartTrigger
rev 1.5, prev_rev 1.4
Index: CartTrigger
===================================================================
RCS file: /var/cvs/xmldocs/refs/CartTrigger,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CartTrigger 18 Jul 2007 11:15:08 -0000 1.4
+++ CartTrigger 18 Jul 2007 11:57:34 -0000 1.5
@@ -77,9 +77,31 @@
triggers along the way.
__END__
-__NAME__ example: Specifying CartTrigger
-<programlisting>
-CartTrigger cart_update1 cart_update2
-</programlisting>
+__NAME__ example: Quantity of sub items follows their master item
+The quantity of sub items are automatically changed to the quantity of
+the corresponding master item <emphasis role='bold'>regardless</emphasis>
+of the current quantity.
+
+<programlisting><![CDATA[
+Sub <<EOS
+sub update_cart {
+ my ($cartref, $action, $newref, $oldref, $cartname) = @_;
+
+ # act upon the main cart only
+ return unless $cartname eq 'main';
+
+ if ($action eq 'update' && $newref->{mv_si} == 0
+ && $newref->{quantity} != $oldref->{quantity}) {
+ # update quantities of sub items
+ for my $subref (grep {$_->{mv_mi} eq $newref->{mv_mi}} @$cartref) {
+ $subref->{quantity} = $newref->{quantity};
+ }
+ }
+}
+EOS
+
+CartTrigger update_cart
+CartTriggerQuantity Yes
+]]></programlisting>
__END__
More information about the docs
mailing list