Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

niviche

Pioneers
  • Posts

    54
  • Joined

  • Last visited

Everything posted by niviche

  1. Terra, I think I found a small bug in this contribution. Unlike other payment modules, this one doesn't give any "description" of the payment process to the user on "checkout_confirmation". In other word, the MODULE_PAYMENT_PAYPAL_IPN_TEXT_DESCRIPTION doesn't appear anywhere on this page. I modified the following, which seems to solve this and doesn't break anything. However, can anybody confirm that this modification doesn't mess up with the rest of the contribution? find: } function process_button() { global $customer_id, $order, $languages_id, $currencies, $currency, $cart_PayPal_IPN_ID, $shipping; right before this, replace return false; with return array('title' => MODULE_PAYMENT_PAYPAL_IPN_TEXT_DESCRIPTION); I hope this helps and doesn't break anything.:)
  2. Terra, I agree with the logic of this contribution, and think that it deals with Paypal IPN very well. However, wouldn't it be even better to have the pre-storage of the orders and the stock update taking place when people hit the "confirm order" button (rather than when they enter checkout_confirmation)? This way, there would be less trashed carts stored. Just an idea, I have no idea how to implement this.
  3. Cooch, you are right, we are trying two different things, even though both aim at getting everything right even when the customers doesn't return to the store. How do you want to do this? At which point in the process for the user would everything happen?
  4. Actually, I asked on the Paypal forum, and Germany is the only country where buyers must have a Paypal account to use their credit cards. :-( http://www.pdncommunity.com/pdn/board/mess...ding&page=1
  5. I have tried to solve this, but I can't manage to do it. Therefore, it would be great if somebody can look into this. 1. in the modification I posted above, I moved the stock update from the before_process to the confirmation functions in paypal_ipn. 2. this stock update takes places only if the order is new (i.e. if $update_order = false). 3. I would like to update the stock as well if the order is not new (if $update_order = true). I have tried to copy the stock update code to the update order loop, but I don't manage to get the previously ordered quantities from orders_products table Basically, we need a line like this one: Does anybody know how to insert the correct values for the text in red in the line above?
  6. Wouldn't this defeat the concept of this contribution, though? The customer reaches checkout_process only when he "comes back" from Paypal. In this case, if he pays but closes his browser before coming back to the OSC site, you will get a payment but neither an order nor a stock update. This is an issue that arised with my modification, so I don't think it's been fixed yet. :)
  7. This file goes into a new folder that you create at \catalog\ext\modules\payment\paypal_ipn
  8. The status of the order is set to "Paypal (processing" right when the customer hits checkout_confirmation.php, and the stock update happens right at the same moment in my modification above. Both process take place at the same time. However, if the customer then choses to change his order, his "paypal (processing)" order will get updated next time he hits checkout_confirmation, which doesn't happen yet with the stock update. This is something I will try to look into (but if somebody wants to try, she / he is very welcome :) ).
  9. (I wanted to edit the post I have just made above, but couldn't find any option to do so.) I have found an easier and most efficient way to to have the stock quantities updated before the order is sent to Paypal. This method replaces the one above, you can disregard the post above this one 1 . open catalog\includes\modules\payment\paypal_ipn.php 2. find: //-1.4 tep_db_perform(TABLE_ORDERS, $sql_data_array); $insert_id = tep_db_insert_id(); 3. adds after this: //stock update before payment for Paypal IPN - start // Stock Update - Joao Correia for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { if (STOCK_LIMITED == 'true') { if (DOWNLOAD_ENABLED == 'true') { $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename FROM " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON p.products_id=pa.products_id LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad ON pa.products_attributes_id=pad.products_attributes_id WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"; // Will work with only one option for downloadable products // otherwise, we have to build the query dynamically with a loop $products_attributes = $order->products[$i]['attributes']; if (is_array($products_attributes)) { $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'"; } $stock_query = tep_db_query($stock_query_raw); } else { $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } if (tep_db_num_rows($stock_query) > 0) { $stock_values = tep_db_fetch_array($stock_query); // do not decrement quantities if products_attributes_filename exists if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) { $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty']; } else { $stock_left = $stock_values['products_quantity']; } tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) { tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } } } // Update products_ordered (for bestsellers list) tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } //stock update before payment for Paypal IPN - ends 4. in the same file, find: tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) { tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) 5. replace this by: // tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) { // tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); This should now work with all language, and even if the customer refreshes his browser on the checkout_confirmation page. Known issue: -if the customer chose some item to buy, then chose Paypal as a payment method, comes to the Checkout Confirmation page but then decide to modify his cart, the stock quantites will be updated only with what his cart contained when he first reached the Checkout Confirmation page. Maybe somebody can help to fix this
  10. JonoB and Chooch, I believe that I have at least part of the solution. Here are the modifications to bring to your files to have the stock quantities updated before the order is sent to Paypal, but only if Paypal is the selected payment method. If your customer chooses another payment method, everything is as usual. Note that I am not a programmer at all. I never read a book about Php and never attended a class about this either. Therefore, the code below is probably very, very rough and might break your files. It would be great if a programmer should check this and improve this "ghetto" modification. Known issues: -this will work for one language only -if your customers refresh his browser on "checkout confirmation", or if he goes back somewhere else and comes back there, the stock will be updated several times. :( Here we go: 1. open catalog\includes\languages\(your language)\modules\payment\paypal_ipn.php 2. find the line beginning with: define('MODULE_PAYMENT_PAYPAL_IPN_TEXT_TITLE', note the name of your Paypal IPN module. The default is "PayPal (Credit Card / Debit)" but you can rename it. 3. open catalog\checkout_confirmation.php 4. on or around line 371, find the line: echo $payment_modules->process_button(); 5. right before this add: if ($order->info['payment_method'] =='Paypal') { echo $payment_modules->stock_before_ipn(); } note: if you have renamed your module in step 2, replace the "PayPal (Credit Card / Debit)" with the new name of your module 6. open catalog\includes\classes\payment.php 7. find the line: function before_process() { 8. right before this, add: // stock update before payment for Paypal IPN - start function stock_before_ipn() { if (is_array($this->modules)) { if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) { return $GLOBALS[$this->selected_module]->stock_before_ipn(); } } } // stock update before payment for Paypal IPN - end 9. open \catalog\includes\modules\payment\paypal.ipn.php 10. around line 271, find: function process_button() { 11. right before this line, add: // stock update before payment for Paypal IPN - start function stock_before_ipn() { global $customer_id, $order, $sendto, $billto, $payment, $languages_id, $currencies, $cart, $cart_PayPal_IPN_ID; global $$payment; // initialized for the email confirmation $products_ordered = ''; $subtotal = 0; $total_tax = 0; for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { // Stock Update - Joao Correia if (STOCK_LIMITED == 'true') { if (DOWNLOAD_ENABLED == 'true') { $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename FROM " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON p.products_id=pa.products_id LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad ON pa.products_attributes_id=pad.products_attributes_id WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"; // Will work with only one option for downloadable products // otherwise, we have to build the query dynamically with a loop $products_attributes = $order->products[$i]['attributes']; if (is_array($products_attributes)) { $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'"; } $stock_query = tep_db_query($stock_query_raw); } else { $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } if (tep_db_num_rows($stock_query) > 0) { $stock_values = tep_db_fetch_array($stock_query); // do not decrement quantities if products_attributes_filename exists if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) { $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty']; } else { $stock_left = $stock_values['products_quantity']; } tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) { tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } } } // Update products_ordered (for bestsellers list) tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } } // stock update before payment for Paypal IPN - start 12. stay in paypal_ipn.php and find the line: //------insert customer choosen option to order-------- 13. above this, delete or comment the following paragraph (make sure you backed up your file): // Stock Update - Joao Correia if (STOCK_LIMITED == 'true') { if (DOWNLOAD_ENABLED == 'true') { $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename FROM " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON p.products_id=pa.products_id LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad ON pa.products_attributes_id=pad.products_attributes_id WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"; // Will work with only one option for downloadable products // otherwise, we have to build the query dynamically with a loop $products_attributes = $order->products[$i]['attributes']; if (is_array($products_attributes)) { $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'"; } $stock_query = tep_db_query($stock_query_raw); } else { $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } if (tep_db_num_rows($stock_query) > 0) { $stock_values = tep_db_fetch_array($stock_query); // do not decrement quantities if products_attributes_filename exists if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) { $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty']; } else { $stock_left = $stock_values['products_quantity']; } tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) { tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } } } // Update products_ordered (for bestsellers list) tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); A last note: I am testing my shop on a local machine (localhost), meaning that I can not receive payment confirmations from Paypal and can not test the whole process till the end. The modifications above take part of updating the stock before sending the order. However, I'd need somebody to test what happens when the customers goes all the way on Paypal and land back on OSC. I think the stock will not be updated again, but I am not sure. Have fun. Hopefully somebody can improve these modifcations and help fix the issues listed above.
  11. I am sorry to ask, but where is this option and how is it called? I just can't find it.
  12. I am not at all a programmer, but here's what I saw: -the stock update is passed in paypal_ipn in the "before_process()" function, which is called at the beginng of checkout_process. -I believe that when a customer send his order (at the end of checkout_confirmation), the system calls the function "process_button()" If we move the stock update from "before_process" to "process_button", and call the Paypal IPN before_process function when the customer clicks to send his order, then the stock update might happen right when the order is sent to Paypal. It would be something like: 1. customer is on checkout_confirmation 2. -if the payment method is "paypal ipn" and he clicks to send his order, we call the "process_button" function from Paypal IPN -> stock update -if the payment method is not "paypal ipn", then the process_button is not the one from Paypal IPN -> it all goes like usual with the other payment method. I have tried to implement this, but I am really, really not a programmer at all, and I just couldn't do it. I had just copied / paste the stock update thing to "process_button", but this didn't work. Can anybody help?
  13. Hello, This is more a question about Paypal's policies than about osCommerce. I hope that this is the right place to ask. -I am setting up an osCommerce shop, and currently testing the IPN and Basic Website Payment features. -I am testing everything through the sandbox, nothing is live at all. -My website is currently just on my computer (localhost), there is nothing on any public server. I have set up a seller account in the sandbox, both "business" and "verified". All the data and info from my site is passed correctly to Paypal, all works well, except this: every time I test a purchase, I get a "Signing up for a PayPal account will be required to complete this purchase.". Whatever the amount of the purchase or the browser (tested in Opera 9, Firefox 2 and IE6), the buyer never gets a chance to pay without having to set up a Paypal Account. Being able to receive payment via credit cards from people without a paypal account is what I am after. So far, this doesn't work at all with the sandbox. How can I solve this problem? -is it due to my location (I am in Germany, and the fake seller I set up in the sandbox is also in Germany)? -is it due to the amount of the purchase (my shop should have orders ranging from US$5 to US$200 max)? -is it due to the fact that I am testing this from localhost (ie the IP of the shop and the IP of the test buyer are the same)? -does it have something to do with the account? This seller in the sandbox is "non-US verified business". To sum-up: what is needed to accept credit card payments from somebody who doesn't have a paypal account? Thank you for your help.
  14. Hello, I have just installed Paypal IPN, it works very well, congratulations. However, I have a small problem with it and could not find an answer in the various threads on this forum about this. Is it possible to update the product quantity when the order gets the status "Preparing [iPN]", not only when it gets back to "Pending"? This way, the quantity is sure to go down (whether or not the order is paid, and whether or not Paypal and my OSC communicate nicely), and I am certain never to have orders for products which I do not have in stock. Rather safe than sorry. :)
  15. You should be able to change the look of the 2gether box in catalog/includes/modules/2gether.php
  16. I seem to have solved my problem (see post above). I don't know if it will work for everybody, but, if you the 2gether contribution conflicts with products with attributes in your store: change in catalog\includes\application.top: the whole case 'add_product' till break; by: case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) { //if (tep_get_products_stock($HTTP_POST_VARS['products_id']) > 0) $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']); $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']); } if (isset($HTTP_POST_VARS['buy_tinn_add']) && is_numeric($HTTP_POST_VARS['buy_tinn_add'])) { // if (tep_get_products_stock($HTTP_POST_VARS['buy_tinn_add']) > 0) { $cart->add_cart($HTTP_POST_VARS['buy_tinn_add'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['buy_tinn_add'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']); // } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break;
  17. I have another problem with this contribution. Maybe somebody can help. It all works perfectly with products without attribute, but, once this contribution is added, I can not add any product with attribute (including downloadable products) in my shopping cart, even if they are not part of a bundle: -if I have a product with only one attrible (=downloadable), it never gets added to the cart. -if the product has several "versions" (for example several sizes or colors), the main product gets added, without any attribute. I know that this has been discussed here before, but has anybody been able to solve this issue? It would be very nice to know what to change to solve this problem. I don't want to bundle any products with attribute, only to be able to have products with attribute being normally put in the cart. :( Thank you very much
  18. Hello, First, to solve the issue I had with tax calculation above, I changed what was posted in this post very slightly. Replace the function process () in catalog/includes/modules/ot_together.php with: function process() { global $order, $currencies, $ot_subtotal, $cart, $together_product_names; $od_amount = $this->calculate_2gether_discount(); if ($od_amount > 0) { $this->deduction = $od_amount; $this->output[] = array('title' => sprintf(MODULE_2GETHER_DISCOUNT_FORMATED_TITLE, $together_product_names), 'text' => sprintf(MODULE_2GETHER_DISCOUNT_FORMATED_TEXT, $currencies->format($od_amount)), 'value' => $od_amount); /*****START_TAX_CALCULATIONS*****/ $discount_percentage = ($od_amount/$order->info['subtotal']); if ($order->info['tax'] > 0) { $tod_amount = ($order->info['tax'] * $discount_percentage); reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $god_amount = $value * $discount_percentage; $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; } } // $order->info['total'] -= $order->info['tax']; $order->info['total'] -= $this->deduction; $order->info['tax'] -= $tod_amount; // $order->info['total'] = ($order->info['total'] - $od_amount) + $order->info['tax']; /*****END_TAX_CALCULATIONS*****/ if ($this->sort_order < $ot_subtotal->sort_order) $order->info['subtotal'] -= $this->deduction; } } However, note that with this method, the tax are correct if 100% of your shopping cart content is a 2gether bundle. If you add any other product (for example from another tax class), the subtotal and total prices stay correct, but the tax amount are wrong.
  19. All right. Sorry, sorry, sorry. I shouldn't have written "useless", I was just trying to help, I didn't want to offend anybody. Had I, I wouldn't have posted all this info.
  20. Nice... All right, I try to see where the problem is, explain where I believe it comes from, what it breaks, and it's not enough. Well, sorry. I guess I should have written "bug report: total amount incorrect if display_price_with_tax is set to true". I just tried to do a little more than that.
  21. All right, sorry for having used the word "useless". I should just have written that, with this bug, the contribution is broken for people using taxes in their shop. I'm really sorry if I offended you. I am deeply thankful for your work on this contribution, obviously, and would just like to help to fix it. After all, it *is* broken in this case.
  22. Oh well. Thank you. I'll still try and fix this, as with this problem, anybody using this contribution and taxes is going to have wrong total prices. So, another things: the discount is always considered as without tax when calculating the tax, but not when calculating the total to which to add the tax (I believe)
  23. I know. Any idea where and how this could be implemented? Basically, there is a moment in the calculation of the price where the discount amount is taken as before tax, and one where it is *after* the tax...
  24. I'll be very happy to do so, but I completely lack any knowledge of php. That's why I am trying to see exactly where the problem is. I'd be happy to help, but I can't do it by myself.
  25. sorry if I am thinking loud here, I am just trying to see how to fix this problem... Actually, the same problem happens with the box displayed on Product_info: It doesn't matter whether you display the prices with or without taxes, the saved amount is still the same. This means that you give a bigger rebate to the people buying outside of the tax zone. Argh.
×
×
  • Create New...