Skip to content

i am getting this error "checkout.js:40 Uncaught TypeError: Cannot read properties of undefined (reading 'deliveryDays') and i have exactly followed the video i dont know whats wrong #148

Open

Description

@uzairhafiz8

i am getting this error in console:

checkout.js:40 Uncaught TypeError: Cannot read properties of undefined (reading 'deliveryDays')
at checkout.js:40:47
at Array.forEach ()
at renderOrderSummary (checkout.js:13:8)
at checkout.js:203:1

i have attached the picture showing where it originates
deliverydayserror

also if anyone wanna get in touch, help explain it or do the rest of the project together, here is my discord:willbettelheim6027

Activity

  1. Fz-Faiz commented on Sep 13, 2024

    @Fz-Faiz

    You can try localStorage.clear() in console
    [
    localStorage clear
    ]

  2. banda-shri1998 commented on Oct 1, 2024

    @banda-shri1998

    adding debugger before the line where error occurs while checking flow of execution becomes much easier to resolve by you own

  3. osmvenkat commented on Oct 31, 2024

    @osmvenkat

    i am getting this error in console:

    checkout.js:40 Uncaught TypeError: Cannot read properties of undefined (reading 'deliveryDays') at checkout.js:40:47 at Array.forEach () at renderOrderSummary (checkout.js:13:8) at checkout.js:203:1

    i have attached the picture showing where it originates deliverydayserror

    also if anyone wanna get in touch, help explain it or do the rest of the project together, here is my discord:willbettelheim6027

    SAME PROBLEM WITH ME DO YOU FIND SOLUTION

  4. banda-shri1998 commented on Nov 2, 2024

    @banda-shri1998

    unable to find you DISCORD here my Discord username : rockingshri27

    i am getting this error in console:
    checkout.js:40 Uncaught TypeError: Cannot read properties of undefined (reading 'deliveryDays') at checkout.js:40:47 at Array.forEach () at renderOrderSummary (checkout.js:13:8) at checkout.js:203:1
    i have attached the picture showing where it originates deliverydayserror
    also if anyone wanna get in touch, help explain it or do the rest of the project together, here is my discord:willbettelheim6027

    SAME PROBLEM WITH ME DO YOU FIND SOLUTION

  5. Roopam-98 commented on Jan 2, 2025

    @Roopam-98

    heyy!! Check if you have imported deliveryOptions correctly! This simply means your current file thinks that deliveryDays doesn't exist which could be import issue or spelling issue of the property!

  6. banda-shri1998 commented on Jan 3, 2025

    @banda-shri1998

    Instagram
    here is my insta ID to contact me so we can solve together

  7. Roopam-98 commented on Jan 4, 2025

    @Roopam-98

    Instagram here is my insta ID to contact me so we can solve together

    Could you share your email? Or maybe your github repo used or amazon clone

  8. banda-shri1998 commented on Jan 5, 2025

    @banda-shri1998
  9. ElementalcodeIn commented on Jan 26, 2025

    @ElementalcodeIn

    Hii... Everyone, so this is the solution of this Error.

    The error Cannot read properties of undefined (reading 'deliveryDays') indicates that

    deliveryOption is undefined at line 32 in checkout.js

    This means that the deliveryOptionId from cartItem does not match any id in deliveryOptions.

    To fix this, you should add a check to ensure deliveryOption is found before trying to access its properties. Here's the updated code:

    ...
    cart.forEach((cartItem) => {
    const productId = cartItem.productId;

    let matchingProduct;

    products.forEach((product) => {
    if (product.id === productId) {
    matchingProduct = product;
    }
    });

    const deliveryOptionId = cartItem.deliveryOptionsId;

    let deliveryOption;

    deliveryOptions.forEach((option) => {
    if (option.id === deliveryOptionId) {
    deliveryOption = option;
    }
    });

    if (!deliveryOption) {
    console.error(Delivery option with id ${deliveryOptionId} not found);
    return;
    }

    const today = dayjs();
    const deliveryDate = today.add(deliveryOption.deliveryDays, "days");
    const dateString = deliveryDate.format('dddd, MMMM D');

    cartSummaryHTMl += `

    Delivery date: ${dateString}
    ... `; }); ...

    This will log an error message if a deliveryOption is not found and prevent the code from trying to access properties of undefined.

    Hope it will help you all and happy coding 👍

  10. Georgeikani commented on Feb 10, 2025

    @Georgeikani

    I had same issues, was stocked for about 3 days, the solution is
    const deliveryDate = today.add(deliveryOptions.deliveryDays, 'days'); they should be an s on the deliveryOption.
    then if it shows again, dont delete the s, just use this command on the console
    localStorage.clear()

    //updating delivery date to the actual date.
    const deliveryOptionsId = cartItem.deliveryOptionsId;
    let deliveryOption;
    deliveryOptions.forEach((Option) =>{
    if(Option.id === deliveryOptionsId){
    deliveryOption = Option
    }
    });

    const today = dayjs();
     const deliveryDate = today.add(deliveryOptions.deliveryDays,'days');  
      const dateString = deliveryDate.format(
        'dddd, MMMM D');
    
  11. Ishaprof0510 commented on Mar 6, 2025

    @Ishaprof0510

    I had same issues, was stocked for about 3 days, the solution is const deliveryDate = today.add(deliveryOptions.deliveryDays, 'days'); they should be an s on the deliveryOption. then if it shows again, dont delete the s, just use this command on the console localStorage.clear()

    //updating delivery date to the actual date. const deliveryOptionsId = cartItem.deliveryOptionsId; let deliveryOption; deliveryOptions.forEach((Option) =>{ if(Option.id === deliveryOptionsId){ deliveryOption = Option } });

    const today = dayjs();
     const deliveryDate = today.add(deliveryOptions.deliveryDays,'days');  
      const dateString = deliveryDate.format(
        'dddd, MMMM D');
    

    Thank You. It finally helped. I used "deliveryOption.deliveryDays" instead of "deliveryOptions.deliveryDays". Such a relief. But, now I am getting an error with my radio button, I am unable to select any option for the delivery :(.

    Can you help please?

  12. Bami97 commented on Aug 22, 2025

    @Bami97

    I have tried all solutions listed but none worked, can someone please help.

  13. Bami97 commented on Aug 22, 2025

    @Bami97

    I had same issues, was stocked for about 3 days, the solution is const deliveryDate = today.add(deliveryOptions.deliveryDays, 'days'); they should be an s on the deliveryOption. then if it shows again, dont delete the s, just use this command on the console localStorage.clear()
    //updating delivery date to the actual date. const deliveryOptionsId = cartItem.deliveryOptionsId; let deliveryOption; deliveryOptions.forEach((Option) =>{ if(Option.id === deliveryOptionsId){ deliveryOption = Option } });

    const today = dayjs();
     const deliveryDate = today.add(deliveryOptions.deliveryDays,'days');  
      const dateString = deliveryDate.format(
        'dddd, MMMM D');
    

    Thank You. It finally helped. I used "deliveryOption.deliveryDays" instead of "deliveryOptions.deliveryDays". Such a relief. But, now I am getting an error with my radio button, I am unable to select any option for the delivery :(.

    Can you help please?

    Hey Ishaprof0510, have you fixed this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions