From 551c22c8baf06c0446b397ad9720d10cb9c88ee3 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Thu, 28 Feb 2013 01:22:55 +0100 Subject: [PATCH] Product ID in cart items internal metadata + alias support. The alias support is implemented in products, but not in market. The product ID in the cart items is useful for plugins that hook the checkout. --- plugins/market | 2 +- plugins/products | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/market b/plugins/market index 496241b..2019715 100755 --- a/plugins/market +++ b/plugins/market @@ -27,7 +27,7 @@ sub command :Tab(market) { $seller = parse_amount($seller) or next; $space = parse_amount($space) or next; - $cart->add(undef, -($seller + $space), $description); + $cart->add(undef, -($seller + $space), $description, {product_id=>$id}); $cart->add($username, 0+$seller, "\$you bought $description") if 0+$seller; return ACCEPT; diff --git a/plugins/products b/plugins/products index 0dc6758..5378f70 100755 --- a/plugins/products +++ b/plugins/products @@ -20,14 +20,17 @@ sub command :Tab(edit) { chomp @$_ for @products; for my $fields (@products) { - my ($id, $price, $description) = @$fields; + my ($ids, $price, $description) = @$fields; - next if $command ne $id; + my @ids = split /,/, $ids; + for my $id (@ids) { + next if $id ne $command; - $price = parse_amount($price) or next; + $price = parse_amount($price) or next; - $cart->add(undef, -$price, $description); - return ACCEPT; + $cart->add(undef, -$price, $description, { product_id => $ids[0] }); + return ACCEPT; + } } return NEXT;