Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Multi_Vendor_Shipping new thread


blucollarguy

Recommended Posts

Ok now I am trying to add Ajax one page checkout:

 

Here is the function I am thinking in function guest_cart I am thinking I need to declare more globals to make it work with MVS correct? I marked the ones that I am not sure if correct with //not sure if correct. Here is the code:

//Ajax one page	
    function guest_cart() {
      global $_POST, $customer_id, $sendto, $billto, $order, $cart, $languages_id, $currency, $currencies, $shipping, $payment, $comments, $customer_default_address_id,  $firstname, $lastname, $email_address, $company, $street_address, $suburb, $city, $state, $country, $telephone, $fax, $customer_zone_id, $customer_country_id, $postcode;

      $this->content_type = $cart->get_content_type();

      if ( ($this->content_type != 'virtual') && ($sendto == false) ) {
        $sendto = $customer_default_address_id;
      }

      if (is_array($sendto) && !empty($sendto)) {
				if (!isset($sendto['country_id'])) $sendto['country_id'] = $sendto['country']['id'];
	
        $country_sendto = tep_get_countries($sendto['country_id'], true);
				$address_format_id = tep_get_address_format_id($sendto['country_id']);

				$shipping_address = array('firstname' => $sendto['firstname'],
				                          'lastname' => $sendto['lastname'],
				                          'company' => (isset($sendto['company']) ? $sendto['company'] : ''),
				                          'street_address' => $sendto['street_address'],
				                          'suburb' => (isset($sendto['suburb']) ? $sendto['suburb'] : ''),
				                          'postcode' => $sendto['postcode'],
//Ajax 	'state' => ((tep_not_null($state)) ? $state : $state),
 							'state' => ((tep_not_null($sendto['state'])) ? $sendto['state'] : ''),
				                          'city' => $sendto['city'],
				                          'zone_id' => (isset($sendto['zone_id']) ? $sendto['zone_id'] : ''),
																	'zone_name' => (isset($sendto['zone_name']) ? $sendto['zone_name'] : ''),
				                          'country_id' => $sendto['country_id'],
				                          'countries_id' => $sendto['country_id'],
				                          'countries_name' => $country_sendto['countries_name'],
				                          'countries_iso_code_2' => $country_sendto['countries_iso_code_2'],
				                          'countries_iso_code_3' => $country_sendto['countries_iso_code_3'],
				                          'address_format_id' => $address_format_id);
      } else {
	
        $shipping_address = array('firstname' => null,
                                  'lastname' => null,
                                  'company' => null,
                                  'street_address' => null,
                                  'suburb' => null,
                                  'postcode' => null,
                                  'city' => null,
                                  'zone_id' => null,
                                  'zone_name' => null,
                                  'country_id' => null,
                                  'countries_id' => null,
                                  'countries_name' => null,
                                  'countries_iso_code_2' => null,
                                  'countries_iso_code_3' => null,
                                  'address_format_id' => 0,
                                  'state' => null);
      }

      if (is_array($billto) && !empty($billto)) {
			if (!isset($billto['country_id'])) $billto['country_id'] = $billto['country']['id'];
	
				$country_billto = tep_get_countries($billto['country_id'], true);
				$address_format_id = tep_get_address_format_id($sendto['country_id']);
				
        $billing_address = array('firstname' => $billto['firstname'],
                                 'lastname' => $billto['lastname'],
                                 'company' => (isset($billto['company']) ? $billto['company'] : ''),
                                 'street_address' => $billto['street_address'],
                                 'suburb' => (isset($billto['suburb']) ? $billto['suburb'] : ''),
                                 'postcode' => $billto['postcode'],
																 'state' => ((tep_not_null($billto['state'])) ? $billto['state'] : ''),
                                 'city' => $billto['city'],
                                 'zone_id' => (isset($billto['zone_id']) ? $billto['zone_id'] : ''),
                                 'zone_name' => (isset($billto['zone_name']) ? $billto['zone_name'] : ''),
                                 'country_id' => $billto['country_id'],
                                 'countries_id' => $billto['country_id'],
                                 'countries_name' => $country_billto['countries_name'],
				                         'countries_iso_code_2' => $country_billto['countries_iso_code_2'],
				                         'countries_iso_code_3' => $country_billto['countries_iso_code_3'],
				                         'address_format_id' => $address_format_id,
       													 'state' => (isset($billto['zone_name']) ? $billto['zone_name'] : ''));
      } else {

        $billing_address = array('firstname' => null,
                                  'lastname' => null,
                                  'company' => null,
                                  'street_address' => null,
                                  'suburb' => null,
                                  'postcode' => null,
                                  'city' => null,
                                  'zone_id' => null,
                                  'zone_name' => null,
                                  'country_id' => null,
                                  'countries_id' => null,
                                  'countries_name' => null,
                                  'countries_iso_code_2' => null,
                                  'countries_iso_code_3' => null,
                                  'address_format_id' => 0,
                                  'state' => null);
      }

      if ($this->content_type == 'virtual') {
        $tax_address = array('entry_country_id' => $billing_address['countries_id'],
                             'entry_zone_id' => $billing_address['zone_id']);
      } else {
        $tax_address = array('entry_country_id' => $shipping_address['countries_id'],
                             'entry_zone_id' => $shipping_address['zone_id']);
      }

      $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID,
                          'currency' => $currency,
                          'currency_value' => $currencies->currencies[$currency]['value'],
                          'payment_method' => $payment,
                          'cc_type' => '',
                          'cc_owner' => '',
                          'cc_number' => '',
                          'cc_expires' => '',
                          'shipping_method' => (is_array($shipping) ? $shipping['title'] : $shipping),
                          'shipping_cost' => (is_array($shipping) ? $shipping['cost'] : ''),
//Ajax            'shipping_method' => $shipping['title'],
//Ajax            'shipping_cost' => $shipping['cost'],
                          'subtotal' => 0,
//MVS Start
                          'shipping_tax' => (is_array($shipping) ? $shipping['shipping_tax_total'] : $shipping_tax_total), //not sure if correct
                          'tax' => (is_array($shipping) ? $shipping['shipping_tax_total'] : ''), //not sure if correct
//MVS End
                          'tax_groups' => array(),
                          'comments' => (tep_session_is_registered('comments') && !empty($comments) ? $comments : ''));

      if (isset($GLOBALS[$payment]) && is_object($GLOBALS[$payment])) {
        if (isset($GLOBALS[$payment]->public_title)) {
          $this->info['payment_method'] = $GLOBALS[$payment]->public_title;
        } else {
          $this->info['payment_method'] = $GLOBALS[$payment]->title;
        }

        if ( isset($GLOBALS[$payment]->order_status) && is_numeric($GLOBALS[$payment]->order_status) && ($GLOBALS[$payment]->order_status > 0) ) {
          $this->info['order_status'] = $GLOBALS[$payment]->order_status;
        }
      }

			$address_format_id = tep_get_address_format_id($customer_country_id);
			$country = tep_get_countries($customer_country_id, true);

      $this->customer = array('firstname' => $customer_address['customers_firstname'],
                              'lastname' => $customer_address['customers_lastname'],
                              'company' => $customer_address['entry_company'],
                              'street_address' => $customer_address['entry_street_address'],
                              'suburb' => $customer_address['entry_suburb'],
                              'city' => $customer_address['entry_city'],
                              'postcode' => $customer_address['entry_postcode'],
                              'state' => ((tep_not_null($customer_address['entry_state'])) ? $customer_address['entry_state'] : $customer_address['zone_name']),
                              'zone_id' => $customer_address['entry_zone_id'],
                              'country' => array('id' => $customer_address['countries_id'], 'title' => $customer_address['countries_name'], 'iso_code_2' => $customer_address['countries_iso_code_2'], 'iso_code_3' => $customer_address['countries_iso_code_3']),
                              'format_id' => $customer_address['address_format_id'],
                              'telephone' => $customer_address['customers_telephone'],
                              'email_address' => $customer_address['customers_email_address']);

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

      $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']);

//MVS start
      $orders_shipping_id = '';
      $check_new_vendor_data_query = tep_db_query("select orders_shipping_id, orders_id, vendors_id, vendors_name, shipping_module, shipping_method, shipping_cost from " . TABLE_ORDERS_SHIPPING . " where orders_id = '" . (int)$order_id . "'");
      while ($checked_data = tep_db_fetch_array($check_new_vendor_data_query)) {
        $this->orders_shipping_id = $checked_data['orders_shipping_id'];
      }
//MVS End

      $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']),
//MVS start
                                        'vendors_id' => $products[$i]['vendors_id'],
                                        'vendors_name' => $products[$i]['vendors_name'],
//MVS end
                                        '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++;
          }
        }

        $shown_price = $currencies->calculate_price($this->products[$index]['final_price'], $this->products[$index]['tax'], $this->products[$index]['qty']);
        $this->info['subtotal'] += $shown_price;

        $products_tax = $this->products[$index]['tax'];
        $products_tax_description = $this->products[$index]['tax_description'];
        if (DISPLAY_PRICE_WITH_TAX == 'true') {
          $this->info['tax'] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
          if (isset($this->info['tax_groups']["$products_tax_description"])) {
            $this->info['tax_groups']["$products_tax_description"] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
          } else {
            $this->info['tax_groups']["$products_tax_description"] = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
          }
        } else {
          $this->info['tax'] += ($products_tax / 100) * $shown_price;
          if (isset($this->info['tax_groups']["$products_tax_description"])) {
            $this->info['tax_groups']["$products_tax_description"] += ($products_tax / 100) * $shown_price;
          } else {
//MVS -- add shipping tax
            $this->info['tax_groups']["$products_tax_description"] = ($products_tax / 100) * $shown_price + $shipping['shipping_tax_total'];
          }
        }

        $index++;
      }

     if (DISPLAY_PRICE_WITH_TAX == 'true') {
        $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'];
      } else {
        $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost'];
      }
    }
  }
?>
Edited by drillsar
Link to comment
Share on other sites

Hi All
 
Just working with MVS 1.3 and installing to osCmax rather than osCommerce, but I think the issue would be the same.
 
1060 - Duplicate column name 'vendors_email'

 

Checking at line 214:

 $vendors_query = tep_db_query("select vendors_id, vendors_name, vendors_email, vendors_contact, vendors_phone1, vendors_phone2, vendors_email, vendors_send_email, vendors_status_send, vendor_street, vendor_add2, vendor_city, vendor_state, vendors_zipcode, vendor_country, vendor_country, vendors_image, account_number, vendors_url, vendor_add_info,  handling_charge, handling_per_box, tare_weight, percent_tare_weight, max_box_weight, zones from " . TABLE_VENDORS . " where vendors_id = '" . (int) $_GET['vendors_id'] . "'");

and sure enough the field is repeated, and again at line 444:

$vendors_content_query_raw = "select vendors_id, vendors_name, vendors_email, vendors_contact, vendors_phone1, vendors_phone2, vendors_email, vendors_send_email, vendors_status_send, vendor_street, vendor_add2, vendor_city, vendor_state, vendors_zipcode, vendor_country, vendor_country, vendors_image, account_number, vendors_url, vendor_add_info, handling_charge, handling_per_box, tare_weight, max_box_weight from " . TABLE_VENDORS . " order by vendors_id";

and then if I fix those up, I get

 

1060 - Duplicate column name 'vendor_country'

 

revisiting the same two lines, 214 and 444, reveals vendor_country is repeated.

 

Removing the repeated field values allows the Vendor Manager admin page to run.

 

 

 

 

 

cheers
Tony
******************************
My oscMax Store RecoverToy :: Antique Toy Car Parts
Tony's Tech Blog
WrenMaxwell WebManagement
******************************

Link to comment
Share on other sites

@@Tony. I converted this code to OscMax awhile ago but for a older version. I will have to check out the email issue. I never tested that part. I know some of the modules need updating. The table module isn't working so note that. Did you check that out?

Edited by drillsar
Link to comment
Share on other sites

@@Tony  That's a bug. Older versions of MySQL would let you get away with duplicate names, and nobody spotted them before or they would have been cleaned up.

 

Thanks for reporting the bug.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Jim, I am now testing my store with the new paypal app. When I checkout it says no shipping. Very strange. Where you think I should look? I am thinking checkout_confirmation page but not sure. This is bugging me

Link to comment
Share on other sites

Paypal runs part of the checkout through its own files, so those need to be modified to use the MVS modules.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

I don't know of anybody who ever succeeded in making Paypal Standard work. The only shopowner that I know of gave up and went to Paypal Pro to avoid it.

 

Paypal IPN might work. I haven't tried it.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...