Amazon-MWS

 view release on metacpan or  search on metacpan

lib/Amazon/MWS/XML/OrderlineItem.pm  view on Meta::CPAN


has ShippingPrice => (is => 'ro',
                      isa => sub { die unless ref($_[0]) eq 'HASH'});

has ShippingTax => (is => 'ro',
                    isa => sub { die unless ref($_[0]) eq 'HASH'});

has ShippingDiscount => (is => 'ro',
                         isa => sub { die unless ref($_[0]) eq 'HASH'});

has ItemTax => (is => 'ro',
                isa => sub { die unless ref($_[0]) eq 'HASH'});

has ConditionId => (is => 'ro');

has ItemPrice => (is => 'ro',
                  isa => sub { die unless ref($_[0]) eq 'HASH'});

has ConditionSubtypeId => (is => 'ro');

has QuantityShipped => (is => 'ro');
has QuantityOrdered => (is => 'ro');

=head2 amazon_order_item

The amazon id for the given item (read-only)

=head2 remote_shop_order_item

Alias for C<amazon_order_item>

=head2 merchant_order_item

Our id (read-write).

=head2 currency

The currency code.

=cut

has merchant_order_item => (is => 'rw');

sub amazon_order_item {
    return shift->OrderItemId;
}

sub remote_shop_order_item {
    return shift->amazon_order_item;
}


sub currency {
    return shift->ItemPrice->{CurrencyCode};
}

=head2 price

Amazon report the item price's as the sum of the items, not the
individual price. So we have to do a division for what we know as the
item's price. This looks ugly anyway.

From
L<http://docs.developer.amazonservices.com/en_US/orders/2013-09-01/Orders_ListOrderItems.html>:

The selling price of the order item. Note that an order item is an
item and a quantity. This means that the value of ItemPrice is equal
to the selling price of the item multiplied by the quantity ordered.
Note that ItemPrice excludes ShippingPrice and GiftWrapPrice.

=cut

sub price {
    my $self = shift;
    return sprintf('%.2f', $self->subtotal / $self->quantity);
}

=head2 shipping

The ShippingPrice amount.

=head2 subtotal

The price of the items for the given quantity (see above, C<price>).

=cut

sub shipping {
    my $self = shift;
    my $shipping = 0;
    if (my $price = $self->ShippingPrice) {
        $shipping = $price->{Amount} || 0;
    }
    return sprintf('%.2f', $shipping);
}

=head2 as_ack_orderline_item_hashref

Return an hashref suitable for the building of an ack order feed.

=cut

=head2 Aliases

=over 4

=item sku (SellerSKU)

=item asin (ASIN)

=item quantity (QuantityOrdered)

=item name (Title)

=back


=cut

sub sku {
    return shift->SellerSKU;



( run in 1.337 second using v1.01-cache-2.11-cpan-39bf76dae61 )