Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Get weight attribute from cart

    General Discussion
    3
    4
    236
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      DaniDen last edited by

      Hello, In cart db I have weight, can I get this attribute from cart?
      I tried this function in toArray

      $data['payment'] = $cart->payment->toArray();
      
              $data['items'] = $cart->items->toArray();
      
              $data['weight'] = $cart->weight->toArray();
      

      For example for address I have $cart->shipping_address
      But for weight exist?

      Please give me some advice on how to proceed

      1 Reply Last reply Reply Quote 0
      • devansh-webkul
        devansh-webkul last edited by

        Hi @DaniDen,

        You need to fetch cart_items from cart. Then grab weight attribute.

        $item->weight

        1 Reply Last reply Reply Quote 0
        • R
          rudiculous last edited by

          @devansh-webkul is there any way to get the total weight of the cart?
          or the only way is to loop over all the cart_items and sum it up?

          1 Reply Last reply Reply Quote 0
          • devansh-webkul
            devansh-webkul last edited by

            Loop it and sum it.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post