Author Topic: How to get cart product data array to the index.php?rt=checkout/payment view ?  (Read 5848 times)

Offline lydmanp

  • Newbie
  • *
  • Posts: 23
  • Karma: +1/-0
    • View Profile
Hi,

i have a problem mainly since i don't know how to get variables into my current site.
With get_defined_vars() function i get a "billion" lines long list of variables we can see from current page.

I want to get the products array but i cannot get how i could get the array eg. for echoing or other statements.
After the array listed below ther is a
[order_info] => Array
        (
         ...
         )

And that one i can "access" => print '<pre>' . htmlspecialchars(print_r($order_info, true)) . '</pre>';

I have this sections in mind:

[order_data:AOrder:private] => Array
                (
                    [store_id] => 0
                    [store_name] =>
                    [store_url] =>
                    [customer_id] =>
                    [customer_group_id] =>
                    [firstname] =>
                    [lastname] =>
                    [email] =>
                    [telephone] =>
                    ...
                    [payment_method] => PayPal Express Checkout
                    [products] => Array
                        (
                           
  • => Array

                                (
                                    [product_id] => 112
                                    [name] => Product name
                                    [model] =>
                                    [option] => Array
                                        (
                                           
  • => Array

                                                (
                                                    [product_option_value_id] => 748
                                                    [product_option_id] => 349
                                                    [name] => send file
                                                    [element_type] => U
                                                    [value] => filename.ext
                                                    [prefix] =>
                                                    [price] => 0.0000
                                                    [sku] =>
                                                    [weight] => 0.00000000
                                                    [weight_type] =>
                                                )

                                        )

                                    [download] => Array
                                        (
                                        )

                                    [quantity] => 5
                                    [price] => 1
                                    [total] => 5
                                    [tax] => 1.2
                                    [stock] => 1
                                    [sku] =>
                                )

                        )

                    [totals] => Array
                        (
                           
  • => Array

                                (
                                    [id] => subtotal
                                    [title] => subtotal:
                                    [text] => 5.00€
                                    [value] => 5
                                    [sort_order] => 1
                                    [total_type] => subtotal
                                )

                            [1] => Array
                                (
                                    [id] => shipping
                                    [title] => shippingfee:
                                    [text] => 8.30€
                                    [value] => 8.30
                                    [sort_order] => 3
                                    [total_type] => shipping
                                )

                            [2] => Array
                                (
                                    [id] => tax
                                    [title] => tax
                                    [text] => 1.20€
                                    [value] => 1.2
                                    [sort_order] => 5.1
                                    [total_type] => tax
                                )

                            [3] => Array
                                (
                                    [id] => total
                                    [title] => total:
                                    [text] => 14.50€
                                    [value] => 14.5
                                    [sort_order] => 1000
                                    [total_type] => total
                                )

                        )

                    [comment] =>
                    [total] => 14.5
                    [language_id] => 2
                    [currency_id] => 2
                    [currency] => EUR
                    [value] => 1.00000000
                    [coupon_id] => 0
                    [ip] => ...
                )

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4152
  • Karma: +251/-9
    • View Profile
    • Ideal Open Source Ecommerce Solution
You can look into checkout/confirmation page as example.
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/pages/checkout/confirm.php

Complete array of order related data is pulled from buildOrderData method
Code: [Select]
$this->data = $order->buildOrderData( $this->session->data );

Product array is $this->data['products']
We need your help to build better free open source eCommerce platform for everyone.
See how you can help

Offline lydmanp

  • Newbie
  • *
  • Posts: 23
  • Karma: +1/-0
    • View Profile
Nice! Thank you for fast reply.
With this code i got it working

$order = new AOrder( Registry::getInstance() );
$this->data = $order->buildOrderData( $that->session->data );                   
//echo var_dump($this->data);
print '<pre>' . htmlspecialchars(print_r($this->data, true)) . '</pre>';
I couldnt post code in code tags, it says i'm not allowed to post external links... so sorry for that.

Since you seem to be good on Abantecart. Could you have a suggestion how i should make a custom order item. (anybody can answer with ideas :)

I want a customer to be able to order a custom priced item from me.
When customer orders item, i will see the order in admin page if customer has gone to the checkout  page just before paypal is initiated. If customer is guided here to leave that area to wait for me to give the prodcut a price, how could i do it (i mean, how could i define a price for a product on an incomplete order/checkout ?)

I tried to do it with creating an inverted coupon. That worked in abantecart side, so creating an coupon with double minus sign and value => --29.90
But paypal wont see this coupon as an item so that does not work. (paypal sees just the tax value part of 29.90).
This would be enough it paypal just would notice the coupon as a product since i can give a coupon a name that would refere to the custom order item.
Cart would be then:
custom order item: 0€
[username] custom order price: 29.90€
shipping: 8€
tax: ...€


Offline lydmanp

  • Newbie
  • *
  • Posts: 23
  • Karma: +1/-0
    • View Profile
Actually its like this.

In admin page i create a coupon with negative value -20.00
When this coupon is processed on my cart, the value will be shown in text field as --20.00

Checking from DB the coupon text shows --20.00€ and the actual value shows 20.00.
When i try to checkout, paypal_Express will fail in an error:
PayPal Express Checkout Error
Error has occured during request. Please try again later.

When choosing paypal standart, it will go to paypal, but the value has been changed to -20.00€.

Offline lydmanp

  • Newbie
  • *
  • Posts: 23
  • Karma: +1/-0
    • View Profile
And one thing more.
If i use the paypal_express (orange paypal logo) button instead of going through checkout and chosing payment option, it works
Paypal shows just total amount (one amount).

I tried to tweek the code so that it would pass the positive value to paypal, but it always returns the error if a positive value is added via coupon towards paypal.

I think the express checkout button works, since it does not compare separate item prices. I just cant find what part is doing the checking of coupon value (if that's even the case why it fails ?)

Offline lydmanp

  • Newbie
  • *
  • Posts: 23
  • Karma: +1/-0
    • View Profile
Hello,

after turning everything in and out, i found a quite good way of doing this.
Let me share this:

Product specific PROMOTIONS :) and even further PROMOTIONS that can be bound to specific USER GROUPS!
Thats it. When customer enters as a new person to the webstore, the price is 0. When i get the custom order info i can take the name of the person, add this name as customer group and apply this customer group as a PROMOTION to the custom product. This way, new customers will always see custom product as price 0.
Aftert customer placed and paid his order, i will just remove the PROMOTION and thats that. If the same customer returns with a new custom order, again i can create a new custom price PROMOTION.

There is still couple of issues related to 0 priced prodcuts in the cart => like when they go and order the cart even though custom priced product is not yet defined with a price.
At this point i could make use of the product code and product price in an if statement to check 

pseudocode:
Code: [Select]
If (item_id = 12 & item_id_price) = 0 {
   => at checkout button press, skip paypal redirection and go to info page stating => please wait for the custom order to be priced. If you want to order all the other items, remove the custom order and try to checkout again.
}

 

Powered by SMFPacks Social Login Mod