Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PHP formatting question


daver6

Recommended Posts

Posted

I've got the Viaklix contribution working well (http://www.oscommerce.com/community/contributions,1896). However, the website owner wants the Product information included in the Viaklix order response. Product details (description, options, quantity) are available in the order.php file and are in my Viaklix setup. I've added the following code to viaklix.php, but it's not picking up the data from order.php as it is with the calls for billing and customer data above and below the offset line.

 

viaklix.php addition

 

    tep_draw_hidden_field('ssl_avs_zip', $order->billing['postcode']) .
   tep_draw_hidden_field('ssl_country', $order->billing['country']['title']) .
tep_draw_hidden_field('ssl_description', $order->products['name']['option']['qty']) .
   tep_draw_hidden_field('ssl_phone', $order->customer['telephone']) .
   tep_draw_hidden_field('ssl_email', $order->customer['email_address']) .

 

order.php arrays

 

      $this->billing = array('firstname' => $billing_address['entry_firstname'],
                            'lastname' => $billing_address['entry_lastname'],
                            'company' => $billing_address['entry_company'],
                            'street_address' => $billing_address['entry_street_address'],
                            'suburb' => $billing_address['entry_suburb'],
                            'city' => $billing_address['entry_city'],
                            'postcode' => $billing_address['entry_postcode'],
                            'state' => ((tep_not_null($billing_address['entry_state'])) ? $billing_address['entry_state'] : $billing_address['zone_name']),
                            'zone_id' => $billing_address['entry_zone_id'],
                            'country' => array('id' => $billing_address['countries_id'], 'title' => $billing_address['countries_name'], 'iso_code_2' => $billing_address['countries_iso_code_2'], 'iso_code_3' => $billing_address['countries_iso_code_3']),
                            'country_id' => $billing_address['entry_country_id'],
                            'format_id' => $billing_address['address_format_id']);

     $index = 0;
     $products = $cart->get_products();
     for ($i=0, $n=sizeof($products); $i<$n; $i++) {
       $this->products[$index] = array('qty' => $products[$i]['quantity'],
                                       'name' => $products[$i]['name'],
                                       'model' => $products[$i]['model'],
                                       'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']),
                                       'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']),
                                       'price' => $products[$i]['price'],
                                       'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),
                                       'weight' => $products[$i]['weight'],
                                       'id' => $products[$i]['id']);

       if ($products[$i]['attributes']) {
         $subindex = 0;
         reset($products[$i]['attributes']);
         while (list($option, $value) = each($products[$i]['attributes'])) {
           $attributes_query = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'");
           $attributes = tep_db_fetch_array($attributes_query);

           $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'],
                                                                    'value' => $attributes['products_options_values_name'],
                                                                    'option_id' => $option,
                                                                    'value_id' => $value,
                                                                    'prefix' => $attributes['price_prefix'],
                                                                    'price' => $attributes['options_values_price']);

           $subindex++;
         }

 

 

I'm pretty sure this is the right approach, but I'm missing something - probably in the order.php file format for the products array, which is slightly different from the billing and customer arrays. I can substitute another array call with the same ssl define and it works fine.

 

Does anyone see what my error is? It's not the three descriptors (name, option, qty) since it doesn't work with only one of them either. It doesn't generate any errors. It just doesn't work.

 

Thanks in advance.

Archived

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

×
×
  • Create New...