Skip to content

Custom shopping cart check API plugin not working for Angular Shop 9.3.1 #509

Description

@gitpm

Is this a regression?

Yes

Severity

🟠 Major – significantly affects usability

Please provide the branch(es) you discovered this issue in

v93

Environment Details

edge

Please provide a minimal set of steps to reproduce the issue

  1. Create a custom shopping cart check in the API according to the official documentation.
    see: https://github.com/OneIdentity/IdentityManager.ApiSdk/blob/v93/doc/05-composition-api-plugins.md

  2. Fix the custom shopping cart item check by adding an empty constructor to the Sample CartItemCheck.
    (Annotation if you don't fix it you will get an error during runtime)

Image

add: "public SampleCheck() { } " to the code

public class SampleCheck : ICartItemCheck    { 
        private readonly ICartItemCheckContext _context;  
        public SampleCheck() { }  '<-- add this line !!! 
        public SampleCheck(ICartItemCheckContext context) {  
           ...

=> result; no servor occurs during runtime

  1. Modify the SampleCheck- ProcessAsync-Task, in that way that the task always sets the Status to: CheckStatus.Error
internal async Task ProcessAsync(CancellationToken ct = default)        {
             Status = CheckStatus.Error; '<-- set Status to Error, independent from context
   }

public CheckStatus Status { get; set; } = CheckStatus.Pending;
  1. Add three products to the shopping cart
  2. Goto the shopping cart
  3. Perform a check to the shopping cart

Description

The modified SampleCheck: ICartItemCheck was modified to return always CheckStatus: Error;
Hence all(!!!) products should have the CheckStatus: Error

But in UI-Result only one Product has a CheckStatus: Error, where else the other two products are marked with CheckStatus: ok:

Image

Describe what you expected to happen versus what actually happened

As the SampleCheck always returns CheckStatus.Error in this case all three products should be marked to have an "Fehler" in the ui

Relevant logs or console output

Add a screenshot(s) if that helps illustrate the problem

No response

Suggested Fix

No response

Anything else?

The fact that the SampleCheck - class is instantiated without an context is an error in itself, because a SampleCheck - instance without a context cannot decide if the status is error or success and therefore it makes no sense. But exactly this happens. So I assume that is already the error. I assume if you find the codeline where the ICartItemCheck is instantiated without a context you found the bug.

Image

Before submitting...

  • I have searched for existing issues that match this one on github and on the community support page
  • I have included all necessary details to reproduce this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions