function submit_to_2co() { $eStore_default_currency = get_option('cart_payment_currency'); $eStore_return_url = get_option('cart_return_from_paypal_url'); $eStore_sandbox_enabled = get_option('eStore_cart_enable_sandbox'); $my2CO = new TwoCo(); // Specify your 2CheckOut vendor id $vendor_id = get_option('eStore_2co_vendor_id'); $my2CO->addField('sid', $vendor_id); if (!empty($eStore_default_currency)) { $tco_currency = $eStore_default_currency; } else { $tco_currency = 'USD'; } $my2CO->addField('tco_currency', $tco_currency); //use list_currency // Save the order details $uniqueId = uniqid(); eStore_save_order_details($uniqueId); // Specify the order information $my2CO->addField('id_type', '1'); $my2CO->addField('cart_order_id', $uniqueId); // ======================= global $wpdb; $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME; $count = 1; $total = 0; foreach ($_SESSION['eStore_cart'] as $item) { $id = $item['item_number']; $ret_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$id}'", OBJECT); $rounded_price = round($item['price'], 2); $my2CO->addField("c_name_{$count}", htmlspecialchars($item['name'])); $my2CO->addField("c_description_{$count}", htmlspecialchars($item['name'])); $my2CO->addField("c_price_{$count}", $rounded_price); //$my2CO->addField("quantity_$count", $item['quantity']); //$my2CO->addField("c_prod_$count", $item['item_number']); $my2CO->addField("c_prod_{$count}", $item['item_number'] . ',' . $item['quantity']); if (empty($item['shipping'])) { $my2CO->addField("c_tangible_{$count}", 'N'); } else { $my2CO->addField("c_tangible_{$count}", 'Y'); } $total += $rounded_price * $item['quantity']; $count++; } //Specify the url where 2CO will return the custoemr after payment $total_items_in_cart = count($_SESSION['eStore_cart']); if ($total_items_in_cart == 1 && !empty($ret_product->return_url)) { $my2CO->addField('return_url', $ret_product->return_url); } else { if (!empty($eStore_return_url)) { $my2CO->addField('return_url', $eStore_return_url); } } if ($_SESSION['eStore_cart_postage_cost'] > 0) { $rounded_shipping = round($_SESSION['eStore_cart_postage_cost'], 2); $my2CO->addField("c_name_{$count}", "Shipping"); $my2CO->addField("c_description_{$count}", "Shipping"); $my2CO->addField("c_price_{$count}", $rounded_shipping); $my2CO->addField("c_prod_{$count}", "SHIPPING" . ',' . "1"); } $grand_total = $total + $rounded_shipping + $_SESSION['eStore_cart_total_tax']; $grand_total = round($grand_total, 2); $my2CO->addField('total', $grand_total); //$my2CO->addField('sh_cost', $_SESSION['eStore_cart_postage_cost']); //======================== //$my2CO->addField('pay_method', "CC"); //$my2CO->addField('skip_landing', "1"); //======================== if (get_option('eStore_auto_product_delivery') != '') { $notify = WP_ESTORE_URL . '/eStore_2co_ipn.php'; $my2CO->addField('x_Receipt_Link_URL', $notify); } $custom_field_val = eStore_get_custom_field_value(); $my2CO->addField('custom', $custom_field_val); // Enable test mode if needed if ($eStore_sandbox_enabled) { $my2CO->enableTestMode(); } // Lets clear the cart reset_eStore_cart(); $my2CO->submitPayment2(WP_ESTORE_CLICK_HERE); }