Jump to content

Appeler correctement une variable


Recommended Posts

Bonjour,

J'ai un petit souci je n'arrive pas à appeler correctement la variable formatted_date. J'ai presque tout essayé en vain. Une idée ?

Merci

$deliveries	=
Array (2)
value => Array (1)
  0 => Array (1)
    0 => EDelivery Object (22)
       ->id_product = 378
       ->id_product_attribute = 0
       ->picking_date = "2021-09-01 00:00:00"
       ->delivery_min = "02-09-2021"
       ->delivery_max = "03-09-2021"
       ->delivery_cmp_min = "2021-09-02 00:00:00"
       ->delivery_cmp_max = "2021-09-03 00:00:00"
       ->initial_date = "2021-09-01 00:00:00"
       ->picking_limit = "15:00"
       ->picking_limits = Array (7)
        0 => "15:00"
        1 => "15:00"
        2 => "15:00"
        3 => "15:00"
        4 => "15:00"
        5 => "15:00"
        6 => "15:00"
       ->position = "0"
       ->id_range_weight = null
       ->id_range_price = null
       ->price = null
       ->is_free = null
       ->delay = "Livraison :"
       ->tot = false
       ->dp = DeliveryProduct Object (27)
         ->id_product = 378
         ->id_product_attribute = 0
         ->id_default_attribute = null
         ->id_category_default = 43
         ->id_manufacturer = "4"
         ->id_supplier = "0"
         ->id_shop = 1
         ->width = 0
         ->height = 0
         ->depth = 0
         ->weight = 0
         ->isOOS = true
         ->canOOS = true
         ->oos_add_days = 2
         ->picking_days = null
         ->add_picking_days = "0"
         ->is_pack = false
         ->is_release = true
         ->release_date = "2021-09-01"
         ->is_virtual = "0"
         ->is_available = false
         ->available_date = ""
         ->quantity = 0
         ->quantity_wanted = 1
         ->message = null
         ->formatted_date = "mer. 1 septembre"

 

Link to comment
Share on other sites

57 minutes ago, SmartDataSoft said:

attribuez d'abord la valeur à une variable de premier niveau. puis essayez d'accéder à la valeur

Ca fonctionne avec d'autres variables j'ai juste besoin de la syntaxe pour accéder à celle-ci, qui n'est visiblement pas bonne dans ce que j'ai essayé

Link to comment
Share on other sites

On a pas tout pour vous répondre mais en interprétante +/- ce que vous avez mis je dirais sûrement

{$deliveries.0.0->dp->formated_date} ou {$deliveries.value.0.0->dp->formated_date}

un var_dump copié en mode code permettrait de trouver la bonne syntaxe

Edited by doekia (see edit history)
Link to comment
Share on other sites

21 minutes ago, doekia said:

On a pas tout pour vous répondre mais en interprétante +/- ce que vous avez mis je dirais sûrement

{$deliveries.0.0->dp->formated_date} ou {$deliveries.value.0.0->dp->formated_date}

un var_dump copié en mode code permettrait de trouver la bonne syntaxe

Non ca ne fonctionne pas avec aucune des deux.

Voici le var_dump

array(1) { [0]=> array(1) { [0]=> object(EDelivery)#927 (22) { ["id_product"]=> int(374) ["id_product_attribute"]=> int(0) ["picking_date"]=> string(19) "2021-09-01 00:00:00" ["delivery_min"]=> string(10) "02-09-2021" ["delivery_max"]=> string(10) "03-09-2021" ["delivery_cmp_min"]=> string(19) "2021-09-02 00:00:00" ["delivery_cmp_max"]=> string(19) "2021-09-03 00:00:00" ["initial_date"]=> string(19) "2021-09-01 00:00:00" ["picking_limit"]=> string(5) "15:00" ["picking_limits"]=> array(7) { [0]=> string(5) "15:00" [1]=> string(5) "15:00" [2]=> string(5) "15:00" [3]=> string(5) "15:00" [4]=> string(5) "15:00" [5]=> string(5) "15:00" [6]=> string(5) "15:00" } ["position"]=> string(1) "0" ["id_range_weight"]=> NULL ["id_range_price"]=> NULL ["price"]=> NULL ["is_free"]=> NULL ["delay"]=> string(11) "Livraison :" ["tot"]=> bool(false) ["dp"]=> object(DeliveryProduct)#935 (29) { ["id_product"]=> int(374) ["id_product_attribute"]=> int(0) ["id_default_attribute"]=> NULL ["id_category_default"]=> int(11) ["id_manufacturer"]=> string(1) "4" ["id_supplier"]=> string(1) "0" ["id_shop"]=> int(1) ["width"]=> int(0) ["height"]=> int(0) ["depth"]=> int(0) ["weight"]=> int(0) ["isOOS"]=> bool(true) ["canOOS"]=> bool(true) ["oos_add_days"]=> int(2) ["picking_days"]=> NULL ["add_picking_days"]=> string(1) "0" ["is_pack"]=> bool(false) ["is_release"]=> bool(true) ["release_date"]=> string(10) "2021-09-01" ["is_virtual"]=> string(1) "0" ["is_available"]=> bool(false) ["available_date"]=> string(0) "" ["quantity"]=> int(0) ["quantity_wanted"]=> int(1) ["message"]=> NULL ["release_data":"DeliveryProduct":private]=> NULL ["available_data":"DeliveryProduct":private]=> NULL ["formatted_date"]=> string(17) "mer. 1 septembre" ["msg"]=> string(49) "Commandez maintenant pour une livraison le {date}" } ["special_encoding"]=> string(0) "" ["dc"]=> object(DeliveryCarrier)#925 (20) { ["id_carrier"]=> string(2) "19" ["id_reference"]=> string(1) "8" ["is_default"]=> bool(true) ["name"]=> string(22) "Livraison standard DPD" ["position"]=> string(1) "0" ["picking_limits"]=> array(7) { [0]=> string(5) "15:00" [1]=> string(5) "15:00" [2]=> string(5) "15:00" [3]=> string(5) "15:00" [4]=> string(5) "15:00" [5]=> string(5) "15:00" [6]=> string(5) "15:00" } ["picking_days"]=> string(7) "1111100" ["shippingdays"]=> string(7) "1111110" ["shipping_method"]=> string(1) "2" ["min"]=> string(1) "1" ["max"]=> string(1) "2" ["max_width"]=> string(1) "0" ["max_height"]=> string(1) "0" ["max_depth"]=> string(1) "0" ["active"]=> string(1) "1" ["range_behavior"]=> string(1) "0" ["delay"]=> string(11) "Livraison :" ["is_free"]=> string(1) "0" ["ignore_picking"]=> bool(false) ["shipping_handling"]=> string(1) "0" } ["name"]=> string(22) "Livraison standard DPD" ["shipping_day"]=> string(19) "2021-09-01 00:00:00" } } }

 

Edited by @rthur (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...