Forums / General Questions / Easy Question for someone good at PHP

Easy Question for someone good at PHP

Views: 718

Results 1 to 5 of 5
27 Apr 2011, 3:05 PM
#1
timhersh avatar

timhersh

Zen Follower

Join Date:
Aug 2008
Posts:
274
Plugin Contributions:
0

Easy Question for someone good at PHP

I am editing one of my shipping modules.

BAsically I am checking to see if someone ordered an item from a category, if they did I need to add $15

I am very close to having it figured out but I have a syntac error I can't figure out.

This code is in my item.php page. When I enter it the shipping page pulls up blank and when I research it this is the error message. I'm not sure what else to put to make it work

here is the error


[27-Apr-2011 09:41:12] PHP Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/image/public_html/grimmandgorly.com/cart/includes/modules/shipping/item.php on line 131

*****here is the code, line 131 is this one

if ($this->$chk_flowers >0) {'cost' => ('cost' + 15)};


global $cart;
$chk_flowers = $_SESSION['cart']->in_cart_check('master_categories_id','14');

						  if ($this->$chk_flowers >0) {'cost' => ('cost' + 15)};	

thanks

27 Apr 2011, 3:15 PM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Easy Question for someone good at PHP

timhersh:

*****here is the code, line 131 is this one

if ($this->$chk_flowers >0) {'cost' => ('cost' + 15)};

Try changing that line to read:

if ($this->chk_flowers >0) {'cost' => ('cost' + 15)};

The problem, as far as I can see is the double use of the $ operand

if ($chk_flowers >0) {'cost' => ('cost' + 15)};

will probably also work

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

27 Apr 2011, 3:21 PM
#3
toniscraparoni avatar

toniscraparoni

Zen Follower

Join Date:
Apr 2009
Posts:
158
Plugin Contributions:
0

Re: Easy Question for someone good at PHP

Hope I'm not overstating my PHP skills by replying to this post. ;)

In looking at my item.php file from 1.3.9h, it only has 101 lines. Where is the rest of the code you've added? Without seeing that, I'm going to guess the array you're referring to in your condition hasn't been properly defined.

Hope this helps! :)

Good catch, Rod! We must have been typing at the same time. My eye went right past that. Still working on my coffee. :P

If you want something done right, you have to get Zenned.
♥-My Zen Cart Mods-♥

27 Apr 2011, 3:28 PM
#4
timhersh avatar

timhersh

Zen Follower

Join Date:
Aug 2008
Posts:
274
Plugin Contributions:
0

Re: Easy Question for someone good at PHP

Thanks, I am editing the other item.php, under includes/includes/modules/shipping

I did try that solution and I am still getting the same error message

here is the error

[27-Apr-2011 10:26:39] PHP Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/image/public_html/grimmandgorly.com/cart/includes/modules/shipping/item.php on line 131

here is what I have for the code now


global $cart;
$chk_flowers = $_SESSION['cart']->in_cart_check('master_categories_id','14');

if ($chk_flowers >0) {'cost'=>('cost' + 15)};

  if ($this->tax_class > 0) {

    $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);

  }

any ideas??? thanks

27 Apr 2011, 5:14 PM
#5
timhersh avatar

timhersh

Zen Follower

Join Date:
Aug 2008
Posts:
274
Plugin Contributions:
0

Re: Easy Question for someone good at PHP

Any ideas, I have tried everything. Pretty much I just need to add $15 to the shipping cost if there is anything in category 14. I think I have it almost correct but keep getting the \ unexpected T_DOUBLE_ARROW