Jump to content

I need to add PICK UP DATE and DROP OF DATE (" Booking period ") to the invoice. I used the code below, and doesn't work with me, can you help me please !


faysal f

Recommended Posts

oreach ($order_details as $key_order => $val_order) {
            $info = new ApcarrentalOrder();
            $info = $info->getOrderByIdProduct($val_order['id_order'], $val_order['product_id']);
            $info = $info[0];
            $order_details[$key_order]['date_from'] = $info['date_from'];
            $order_details[$key_order]['date_to'] = $info['date_to'];
            $service = explode(',', $info['service']);
            if (!empty($service)) {
                foreach ($service as $key_s => $val_s) {
                    $service[$key_s] = new ApcarrentalService($val_s, $id_lang);
                }
            }
            $order_details[$key_order]['service'] = $service;
        }

        $data = array(
            'baseurl' => Context::getContext()->shop->getBaseURL(true, true),
            'order' => $this->order,
            'order_invoice' => $this->order_invoice,
            'order_details' => $order_details,
            'carrier' => $carrier,
            'cart_rules' => $cart_rules,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'addresses' => array('invoice' => $invoice_address, 'delivery' => $delivery_address),
            'tax_excluded_display' => $tax_excluded_display,
            'display_product_images' => $display_product_images,
            'layout' => $layout,
            'tax_tab' => $this->getTaxTabContent(),
            'customer' => $customer,
            'footer' => $footer,
            'ps_price_compute_precision' => _PS_PRICE_COMPUTE_PRECISION_,
            'round_type' => $round_type,
            'legal_free_text' => $legal_free_text,
        );
        if (Tools::getValue('debug')) {
            die(Tools::jsonEncode($data));
        }
        $this->smarty->assign($data);
       

 

========in tpl file I call variables date_from and date_to and dosen't work ============

{foreach $order_details as $key_order => $val_order}
        {cycle values=["color_line_even", "color_line_odd"] assign=bgcolor_class}
        <tr class="product {$bgcolor_class}">                  
            <td class="product center">
                {$key_order.val_order.date_from}
            </td>
            <td class="product center">
                {$key_order.val_order.date_to}
            </td>

        </tr>
    {/foreach}

=============

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

If I were you, I would check this:

before this line:

$this->smarty->assign($data);

check if $order_details have correct data, check if there are date_from and date_to

Then in your tpl use dump function and dump like this:

{dump($order_details)}

Check if this has the valid values you are looking for

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

On 8/17/2022 at 11:46 AM, stifler97 said:

If I were you, I would check this:

before this line:

$this->smarty->assign($data);

check if $order_details have correct data, check if there are date_from and date_to

Then in your tpl use dump function and dump like this:

{dump($order_details)}

Check if this has the valid values you are looking for

How can I check it ?

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...