Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4249858
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:27:07+00:00 2026-05-21T04:27:07+00:00

This may be very simplistic question but I can’t find the answer. I want

  • 0

This may be very simplistic question but I can’t find the answer. I want to add a key/value pair to an array in OpenCart but I can’t seem to get it to work. I’m not sure if what I’m adding to is already an array.

In catalog/controller/account/history.php at line 66 there is the definition of an array:-

            $this->data['orders'][] = array(
                'order_id'   => $result['order_id'],
                'name'       => $result['firstname'] . ' ' . $result['lastname'],
                'status'     => $result['status'],
                'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
                'products'   => $product_total,
                'total'      => $this->currency->format($result['total'], $result['currency'], $result['value']),
                'href'       => HTTPS_SERVER . 'index.php?route=account/invoice&order_id=' . $result['order_id']
            );

I want to add to this array using VQMod. VQMod won’t let me replace a line within the definition. I don’t know why, I’ve tried for a couple of hours, it just won’t. So I decided to add a line beneath it like so:-

$this->data[‘orders’][‘amountToPay’] = $paymentState[‘amountToPay’];

This doesn’t work. Not even if I type it directly in the page. I reckon I’ve messed up the syntax but don’t see how unless I’m not understanding the array structure.

Any help appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:27:08+00:00Added an answer on May 21, 2026 at 4:27 am

    You can use the following line –

    $this->data['orders'][sizeof($this->data['orders'])-1]['amountToPay'] = $paymentState['amountToPay']; 
    

    Because your $this->data[‘orders’] is also a numeric indexed array which contains collection of associative array.

    I think your problem will be solved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be a very simple problem, but I couldn't find an answer googleing
This may be a very simplistic question, so apologies in advance, but I am
This may be a basic question, but I could not find an answer for
This may be a very noobie question, but in today's world of web app
This may seem like a very simple question, but I have been struggling with
I realize this may be a very simple question but I need to know
This may be a very old, many times asked question. But I am not
This may be a basic question but I'm not very proficient in SQL Server.
This may seem like a daft question, but i was wondering about how to
The answer to this may very well be no, as much searching has turned

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.