Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_variant logic in cart_route #31

Open
murwiz opened this issue Sep 4, 2014 · 2 comments
Open

find_variant logic in cart_route #31

murwiz opened this issue Sep 4, 2014 · 2 comments

Comments

@murwiz
Copy link

murwiz commented Sep 4, 2014

In Dancer::Plugin::Interchange6::Routes::Cart::cart_route, there is logic for determining a variant based on the submitted form input. In my case, where the variants are being presented as individual products for purchase (a sort of flattened presentation), this results in an odd situation: since I'm submitting nothing but (sku, quantity), there is no distinguishing feature in the variant search, and no variant is found.

for my $name (keys %$attr_ref) {
    $user_input{$name} = param($name);
}

The code above assembles a hash with all the attribute keys, but each of them is an undefined value.

unless ($cart_product = $product->find_variant(\%user_input, \%match_info)) { ... }

The code above ends up looking through all the attribute values for the product, but since none of them were specified in the input, no variant is found.

My workaround:

if (!grep { defined } values %user_input) {
    # No point looking for a variant; we'll just use the product we have.
    $cart_product = $product;
}
else { ... ->find_variant etc. }
@racke
Copy link
Member

racke commented Sep 6, 2014

I going to add a check whether the SKU is canonical. If the SKU is not canonical, it will accepted as is
in case of missing user input.

@SysPete
Copy link
Member

SysPete commented May 12, 2015

@racke did you ever look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants