use utf8; package Dancer2::Plugin::Interchange6::Cart::Product; =head1 NAME Dancer2::Plugin::Interchange6::Cart::Product =head1 DESCRIPTION Extends L. =cut use Interchange6::Types -types; use Moo; use MooseX::CoverableModifiers; extends 'Interchange6::Cart::Product'; use namespace::clean; =head1 ATTRIBUTES See L for inherited attributes. =head2 dbic_product Used to stash the related L object so that other accessors can be lazily built from it on demand. Required. =cut has dbic_product => ( is => 'lazy', required => 1, ); =head2 selling_price Inherited. Lazily set via L. =over =item clearer: clear_selling_price =back L is called whenever L gets called so that possible quantity based pricing is recalculated. =cut has '+selling_price' => ( is => 'lazy', clearer => 1, ); sub _build_selling_price { my $self = shift; $self->dbic_product->selling_price({quantity => $self->quantity}); } after 'set_quantity' => sub { shift->clear_selling_price; }; 1;