Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0b37d054

Von Jan Büren vor fast 2 Jahren hinzugefügt

  • ID 0b37d054b7129b2faa2c63fed344740513bce0ea
  • Vorgänger 71c25621
  • Nachfolger d94b217e

Shopware6: Prozentualen Rabatt aus API auslesen und Konvertieren

Unterschiede anzeigen:

SL/DB/ShopOrder.pm
unit => $part->unit,
position => $_->position,
active_price_source => $_->active_price_source,
discount => $_->discount,
);
}
}@{ $self->shop_order_items };
SL/ShopConnector/Shopware6.pm
my $position = 0;
my $active_price_source = $self->config->price_source;
#Mapping Positions
my %discount_identifier;
foreach my $pos (@positions) {
$position++;
if ($pos->{type} eq 'promotion') {
next unless $pos->{payload}->{discountType} eq 'percentage';
foreach my $discount_pos (@{ $pos->{payload}->{composition} }) {
$discount_identifier{$discount_pos->{id}} = { discount_percentage => $pos->{payload}->{value},
discount_code => $pos->{payload}->{code} };
}
use Data::Dumper;
$main::lxdebug->message(0, 'referenzierte rabatte' . Dumper %discount_identifier);
next;
}
my $price = $::form->round_amount($pos->{unitPrice}, 2); # unit
my %pos_columns = ( description => $pos->{product}->{name},
partnumber => $pos->{product}->{productNumber},
......
shop_trans_id => $pos->{id}, # pos id or shop_trans_id ? or dont care?
shop_order_id => $id,
active_price_source => $active_price_source,
identifier => $pos->{identifier},
);
my $pos_insert = SL::DB::ShopOrderItem->new(%pos_columns);
$pos_insert->save;
}
# add discount if percentage
while ((my $identifier, my $discount_ref) = each (%discount_identifier)) {
# load and update shop order position
my $soi = SL::DB::ShopOrderItem->find_by(identifier => $identifier);
die "No Shop Order Item for discount found! identfier: " . $identifier unless ref $soi eq 'SL::DB::ShopOrderItem';
$soi->update_attributes(discount => $discount_ref->{discount_percentage} / 100,
discount_code => $discount_ref->{discount_code} );
}
$shop_order->positions($position);
if ( $self->config->shipping_costs_parts_id ) {

Auch abrufbar als: Unified diff