Jump to content


Corporate Sponsors


Latest News: (loading..)

JSR

Member Since 17 Feb 2008
Offline Last Active Jan 20 2012, 14:54
-----

Posts I've Made

In Topic: calculate total price of product attributes in cart for shipping modukle

22 July 2011, 13:30

I can't thank u enough for helping me with this problem!
I've tried implementing the code but no change in the way the shipping methods are displayed.
I changed your hack a little bit cause I was getting an "unexpected t_arrow error" and the 2nd if statement looked a bit off to me so it looks like this
// BOF kdm attribute price test
        $attributes_price = 0;
        if($check_flag == true) {
           foreach($order->products as $k=>$v) {
              $a_price = $cart->attributes_price($v['id']);
              $attributes_price = $attributes_price + ($a_price * $v['qty']);
             }
           if($attributes_price > 4.99){ //<--CHANGED THIS
             $check_flag = false;
          }
         }
      
// EOF kdm attribute price test
        }


        if ($check_flag == false){
          $this->enabled = false;
        }
      }
    }
I don't quite get this piece:
 foreach($order->products as $k=>$v) {
              $a_price = $cart->attributes_price($v['id']);
              $attributes_price = $attributes_price + ($a_price * $v['qty']);
             }
What's happening there? :unsure:

In Topic: calculate total price of product attributes in cart for shipping modukle

20 July 2011, 15:27

Oh! Also there is an attribute with a value of 0, otherwise customers would be unable to purchase a product without the cinema coupon... So this is why I need the total value of the attributes in the cart...

In Topic: calculate total price of product attributes in cart for shipping modukle

20 July 2011, 11:50

Hi KDM,

Thanks for taking the time to help me figure this out. You're very kind!
The thing with these attributes is that it's a cinema coupon/ gift card starting at 5 dollars(optional with each product).
And I'd like to make absolutely sure the customer received it with their order.
So they need to sign for the package when they receive it, which results in higher shipping costs.
The cart content could look like this
Example:
Flowers - product id "1" - $35 + (attribute) $5
Balloons - product id "2" - $15 (no attribute /gift card)
Subtotal $55

So I need to check whether or not a coupon is in the cart, If so disable flat shipping no#1
and only offer the shipping method they need to sign for...

I hope you now have a better understanding of what I'm trying to accomplish...

In Topic: calculate total price of product attributes in cart for shipping modukle

18 July 2011, 11:42

Hi KDM,

Sorry for my belated response! I still didn't get this to work, which is odd to me cause it seems pretty straight forward.
So what I was saying is: If there are attributes assigned to the products in the cart and the total amount of these attributes is more then 5 dollars, flat shipping needs to be disabled. I've tried all sorts of things to get this to work, but no luck yet. So confusing...
What would be the way to go if I need the total value of all attributes in the cart? *sigh*

In Topic: calculate total price of product attributes in cart for shipping modukle

14 June 2011, 13:44

Hi KDM,

Thanks for replying! I already tried that route before I decided to go with the shopping cart class ($cart->calculate_price)...
I tried $order->products[$i][$attributes]['total'] but that just gets you the total of attributes added to each product in the order...
What I need is the total price of all added attributes... $order->info['total'] gets you the total amount of the order (products prices+attributes prices)
You follow me?