Jump to content

Archived

This topic is now archived and is closed to further replies.

subzerostudio

simple PHP problem...

Recommended Posts

I'm having an unexpected problem with PHP.. I am simply trying to assign a variable!

This line works:
[code]echo $order->delivery['city'];[/code]  output: BRISTOL

This line DOES NOT work:
[code]
$city = $order->delivery['city'];
echo $city;
[/code] output: NOTHING

Any ideas why?

Mike

Share this post


Link to post
Share on other sites
are you doing both of those on the same page? my question is, on the second example, are you instantiating the $order object before you try to access it?

Share this post


Link to post
Share on other sites
You'd almost have to show us the class since that isn't standard PHP.  Normally that should work fine.

Share this post


Link to post
Share on other sites
[quote author=obsidian link=topic=107644.msg432060#msg432060 date=1157982081]
are you doing both of those on the same page? my question is, on the second example, are you instantiating the $order object before you try to access it?
[/quote]

Yes I am..  I can place the statements directly after each other on the same page.

The class is part of the osCommerce package.  So I don't think posting the class would be wise, as it would involve posting a few thousand lines of code of a couple of different classes..

or maybe I should? hmm..  I'm not *that* confident with PHP, but i expected that to work! ???

Share this post


Link to post
Share on other sites
var_dump returns nothing as well..  Maybe if i put it in context that will help:

[code]
// class methods
    function quote($method = '') {
      global $order;

      //GET THE CITY HERE
      $city = $order->delivery['city'];

      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                    'title' => $city,
                                                    'cost' => MODULE_SHIPPING_FLAT_COST)));

      if ($this->tax_class > 0) {
        $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
      }

      if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

      return $this->quotes;
    }
[/code]

In the above case, 'title' is blank when returned. However if i subsitute this line:

[code]'title' => $city,[/code]

For this:

[code]$order->delivery['city'][/code]

It works.

??

Share this post


Link to post
Share on other sites
var_dump() won't return nothing, it always returns something even if it is just NULL.

var_dump($order->delivery['city']); to see what that returns..

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.