0

i wondering how to combine array also make some value turn to unique and plus some value to make a total:

This is my json encode code if some want to try test it.

{ "error": "", "message": "", "response": { "order_list": [ { "order_sn" : "220703FTRQB9BL", "item_list": [ { "item_id": 7001, "item_name": "smartwatch md41", "item_sku": "smartwatchmd41", "model_id": 74599279361, "model_name": "smartwatch md41,Blue", "model_sku": "smblue", "model_quantity_purchased": 1 }, { "item_id": 7001, "item_name": "smartwatch md41", "item_sku": "smartwatchmd41", "model_id": 74599279362, "model_name": "smartwatch md41,Red", "model_sku": "smred", "model_quantity_purchased": 2 } ] }, { "order_sn" : "220703FTRQBGBA", "item_list": [ { "item_id": 7001, "item_name": "smartwatch md41", "item_sku": "smartwatchmd41", "model_id": 74599279362, "model_name": "smartwatch md41,Red", "model_sku": "smred", "model_quantity_purchased": 3 } ] }, { "order_sn" : "220703FTRQB9RT", "item_list": [ { "item_id": 8009, "item_name": "Basket", "item_sku": "basket", "model_id": 74599279812, "model_name": "Basket BiG,XL", "model_sku": "basketxl", "model_quantity_purchased": 5 } ] }, { "order_sn" : "220703FTRQB9GY", "item_list": [ { "item_id": 8009, "item_name": "Basket", "item_sku": "basket", "model_id": 74599279812, "model_name": "Basket BiG,XL", "model_sku": "basketxl", "model_quantity_purchased": 2 } ] }, { "order_sn" : "220703FTRQB9BA", "item_list": [ { "item_id": 8009, "item_name": "Basket", "item_sku": "basket", "model_id": 74599279812, "model_name": "Basket M,M", "model_sku": "basketm", "model_quantity_purchased": 2 } ] }, { "order_sn" : "220703FTRQB9JW", "item_list": [ { "item_id": 7001, "item_name": "smartwatch md41", "item_sku": "smartwatchmd41", "model_id": 74599279361, "model_name": "smartwatch md41,Blue", "model_sku": "smblue", "model_quantity_purchased": 2 } ] } ] }, "request_id": "3f5d35090159078fd0a2e1602ae9f4f5" }

Below is the output from json

Array
(
    [error] => 
    [message] => 
    [response] => Array
        (
            [order_list] => Array
                (
                    [0] => Array
                        (
                            [order_sn] => 220703FTRQB9BL
                            [item_list] => Array
                                (
                                    [0] => Array
                                        (
                                            [item_id] => 7001
                                            [item_name] => smartwatch md41
                                            [item_sku] => smartwatchmd41
                                            [model_id] => 74599279361
                                            [model_name] => smartwatch md41,Blue
                                            [model_sku] => smblue
                                            [model_quantity_purchased] => 1
                                        )

                                    [1] => Array
                                        (
                                            [item_id] => 7001
                                            [item_name] => smartwatch md41
                                            [item_sku] => smartwatchmd41
                                            [model_id] => 74599279362
                                            [model_name] => smartwatch md41,Red
                                            [model_sku] => smred
                                            [model_quantity_purchased] => 2
                                        )

                                )

                        )

                    [1] => Array
                        (
                            [order_sn] => 220703FTRQBGBA
                            [item_list] => Array
                                (
                                    [0] => Array
                                        (
                                            [item_id] => 7001
                                            [item_name] => smartwatch md41
                                            [item_sku] => smartwatchmd41
                                            [model_id] => 74599279362
                                            [model_name] => smartwatch md41,Red
                                            [model_sku] => smred
                                            [model_quantity_purchased] => 3
                                        )

                                )

                        )

                    [2] => Array
                        (
                            [order_sn] => 220703FTRQB9RT
                            [item_list] => Array
                                (
                                    [0] => Array
                                        (
                                            [item_id] => 8009
                                            [item_name] => Basket
                                            [item_sku] => basket
                                            [model_id] => 74599279812
                                            [model_name] => Basket BiG,XL
                                            [model_sku] => basketxl
                                            [model_quantity_purchased] => 5
                                        )

                                )

                        )

                    [3] => Array
                        (
                            [order_sn] => 220703FTRQB9GY
                            [item_list] => Array
                                (
                                    [0] => Array
                                        (
                                            [item_id] => 8009
                                            [item_name] => Basket
                                            [item_sku] => basket
                                            [model_id] => 74599279812
                                            [model_name] => Basket BiG,XL
                                            [model_sku] => basketxl
                                            [model_quantity_purchased] => 2
                                        )

                                )

                        )

                    [4] => Array
                        (
                            [order_sn] => 220703FTRQB9BA
                            [item_list] => Array
                                (
                                    [0] => Array
                                        (
                                            [item_id] => 8009
                                            [item_name] => Basket
                                            [item_sku] => basket
                                            [model_id] => 74599279812
                                            [model_name] => Basket M,M
                                            [model_sku] => basketm
                                            [model_quantity_purchased] => 2
                                        )

                                )

                        )

                    [5] => Array
                        (
                            [order_sn] => 220703FTRQB9JW
                            [item_list] => Array
                                (
                                    [0] => Array
                                        (
                                            [item_id] => 7001
                                            [item_name] => smartwatch md41
                                            [item_sku] => smartwatchmd41
                                            [model_id] => 74599279361
                                            [model_name] => smartwatch md41,Blue
                                            [model_sku] => smblue
                                            [model_quantity_purchased] => 2
                                        )

                                )

                        )

                )

        )

    [request_id] => 3f5d35090159078fd0a2e1602ae9f4f5
)

What i expect it should be result like this:

See Here

This API result i got from API so i need to to build my picklist item code for my shop. i really hope someone help me. Thanks in advance.

3
  • Does this answer your question? sum of duplicates in array php Commented Jul 5, 2022 at 6:46
  • @vinceAmstoutz i got that one but its not working for multi filter. you can see at here i.imgur.com/UbBD1mN.png . Each Model SKU only got one list only also i dont know how to put order SN inside it. My code is here: pastebin.com/diBG2ES2 Commented Jul 5, 2022 at 8:42
  • @vinceAmstoutz i got that one but its not working for multi filter. you can see at here i.imgur.com/UbBD1mN.png . Each Model SKU only got one list only also i dont know how to put order SN inside it. My code is here: pastebin.com/diBG2ES2 Commented Jul 5, 2022 at 8:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.