Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Order Re-Order Contribution Support


boxtel

Recommended Posts

Just one more thing. When I'm in index.php and click 'In Cart' button where Order History, I get product_info.php and the url it's showing

No product is added to cart. Is this because I put case 'reorder' before case 'cust_order' in application_top.php:

 

case 'notify_remove' :  if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) {
                               $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
                               $check = tep_db_fetch_array($check_query);
                               if ($check['count'] > 0) {
                                 tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
                               }
                               tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))));
                             } else {
                               $navigation->set_snapshot();
                               tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
                             }
                             break;
     case 'reorder' : $reorder_result = tep_reorder($_GET['order_id']);
if ($reorder_result == '') {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING));
} else {
echo $reorder_result;
}
break;

     case 'cust_order' :     if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {
                               // Wish List 2.3 Start
                               tep_db_query("delete from " . TABLE_WISHLIST . " where products_id = '" . $HTTP_GET_VARS['pid'] . "' and customers_id = '" . $customer_id . "'");
                               tep_db_query("delete from " . TABLE_WISHLIST_ATTRIBUTES . " WHERE customers_id=$customer_id AND products_id='" . $HTTP_GET_VARS['pid']."'");
                               // Wish List 2.3 End
                               if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {
                                 tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));
                               } else {
                                 $cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);
                               }
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;

 

Thanks again,

Irina.

Link to comment
Share on other sites

  • Replies 94
  • Created
  • Last Reply

Top Posters In This Topic

Just one more thing. When I'm in index.php and click 'In Cart' button where Order History, I get product_info.php and the url it's showing

No product is added to cart. Is this because I put case 'reorder' before case 'cust_order' in application_top.php:

 

case 'notify_remove' : ?if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$check = tep_db_fetch_array($check_query);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if ($check['count'] > 0) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))));
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?} else {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$navigation->set_snapshot();
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ?case 'reorder' : $reorder_result = tep_reorder($_GET['order_id']);
if ($reorder_result == '') {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING));
} else {
echo $reorder_result;
}
break;

? ? ?case 'cust_order' : ? ? if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// Wish List 2.3 Start
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_db_query("delete from " . TABLE_WISHLIST . " where products_id = '" . $HTTP_GET_VARS['pid'] . "' and customers_id = '" . $customer_id . "'");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_db_query("delete from " . TABLE_WISHLIST_ATTRIBUTES . " WHERE customers_id=$customer_id AND products_id='" . $HTTP_GET_VARS['pid']."'");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// Wish List 2.3 End
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?} else {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?break;

 

Thanks again,

Irina.

 

 

no, it is because the product has attributes :

 

case 'cust_order' : if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {

// Wish List 2.3 Start

tep_db_query("delete from " . TABLE_WISHLIST . " where products_id = '" . $HTTP_GET_VARS['pid'] . "' and customers_id = '" . $customer_id . "'");

tep_db_query("delete from " . TABLE_WISHLIST_ATTRIBUTES . " WHERE customers_id=$customer_id AND products_id='" . $HTTP_GET_VARS['pid']."'");

// Wish List 2.3 End

if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {

tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));

} else {

$cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);

} }

tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

break;

Treasurer MFC

Link to comment
Share on other sites

no, it is because the product has attributes :

 

case 'cust_order' :    if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {

                              // Wish List 2.3 Start

                              tep_db_query("delete from " . TABLE_WISHLIST . " where products_id = '" . $HTTP_GET_VARS['pid'] . "' and customers_id = '" . $customer_id . "'");

                              tep_db_query("delete from " . TABLE_WISHLIST_ATTRIBUTES . " WHERE customers_id=$customer_id AND products_id='" . $HTTP_GET_VARS['pid']."'");

                              // Wish List 2.3 End

                              if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {

                                tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));

                              } else {

                                $cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);

                              }                            }

                            tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

                            break;

Is it any way I can go around this attributes and make the function work properly? I just want it add to cart the exact same thing with the exact same attributes. If I place case 'reorder' just after case 'cust_order':

 

 }
                             break;
     case 'cust_order' :     if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid']));
     case 'reorder' : $reorder_result = tep_reorder($_GET['order_id']);
if ($reorder_result == '') {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING));
} else {
echo $reorder_result;
}
break;
{
                               // Wish List 2.3 Start
                               tep_db_query("delete from " . TABLE_WISHLIST . " where products_id = '" . $HTTP_GET_VARS['pid'] . "' and customers_id = '" . $customer_id . "'");
                               tep_db_query("delete from " . TABLE_WISHLIST_ATTRIBUTES . " WHERE customers_id=$customer_id AND products_id='" . $HTTP_GET_VARS['pid']."'");
                               // Wish List 2.3 End
                               if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {
                                 tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));
                               } else {
                                 $cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);
                               }
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;

I get the following text at the top of index.php :

 

Reorder incomplete

No products found to add

with the url

 

What am I doing wrong? :(

Thanks a lot,

Irina.

Link to comment
Share on other sites

Is it any way I can go around this attributes and make the function work properly? I just want it add to cart the exact same thing with the exact same attributes. If I place case 'reorder' just after case 'cust_order':

 

                       

 }
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ?case 'cust_order' : ? ? if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid']));
? ? ?case 'reorder' : $reorder_result = tep_reorder($_GET['order_id']);
if ($reorder_result == '') {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING));
} else {
echo $reorder_result;
}
break;
{
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// Wish List 2.3 Start
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_db_query("delete from " . TABLE_WISHLIST . " where products_id = '" . $HTTP_GET_VARS['pid'] . "' and customers_id = '" . $customer_id . "'");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_db_query("delete from " . TABLE_WISHLIST_ATTRIBUTES . " WHERE customers_id=$customer_id AND products_id='" . $HTTP_GET_VARS['pid']."'");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// Wish List 2.3 End
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?} else {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?break;

I get the following text at the top of index.php :

with the url

 

What am I doing wrong?  :(

Thanks a lot,

Irina.

 

well, you are missing the point.

 

that box shows the last product(s) the customer ordered and from that they can add that product to the cart. But normally you are always directed to the product page first if the product has attributes because only there you can set them.

 

The function "cust_order" does this and it has nothing to do with "reorder".

They are not executed in sequence but one at a time as separate called functions.

"cust_order" needs a product id.

"reorder" needs an order id.

 

So if you want to use reorder from a box on the index page, you need to create one that lists the last orders (not ordered products) and call the reorder function from there.

Treasurer MFC

Link to comment
Share on other sites

well, you are missing the point.

 

that box shows the last product(s) the customer ordered and from that they can add that product to the cart. But normally you are always directed to the product page first if the product has attributes because only there you can set them.

 

The function "cust_order" does this and it has nothing to do with "reorder".

They are not executed in sequence but one at a time as separate called functions.

"cust_order" needs a product id.

"reorder" needs an order id.

 

So if you want to use reorder from a box on the index page, you need to create one that lists the last orders (not ordered products) and call the reorder function from there.

 

so create a file called order_order_history.php in includes/boxes

 

put this in that file :

 

<?php

if (tep_session_is_registered('customer_id')) {

$orders_query = tep_db_query("select orders_id

from " . TABLE_ORDERS . "

where customers_id = '" . (int)$customer_id . "'

order by date_purchased desc

limit 4 ");

if (tep_db_num_rows($orders_query)) {

?>

<tr>

<td>

<?php

$info_box_contents = array();

$info_box_contents[] = array('text' => BOX_HEADING_CUSTOMER_ORDERS);

 

new infoBoxHeading($info_box_contents, true, true);

$customer_orders_string .= '<table width="100%">';

 

while ($orders = tep_db_fetch_array($orders_query)) {

$customer_orders_string .= ' <tr>' .

' <td class="infoBoxContents"><a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL') . '">#' . $orders['orders_id'] . '</a></td>' .

' <td class="infoBoxContents" align="right" valign="top"><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=reorder&order_id=' . $orders['orders_id']) . '">' . tep_image(DIR_WS_ICONS . 'cart.gif', ICON_CART) . '</a></td>' .

' </tr>';

}

$customer_orders_string .= '</table>';

 

$info_box_contents = array();

$info_box_contents[] = array('text' => $customer_orders_string);

 

new infoBox($info_box_contents);

?>

</td>

</tr>

<?php

}

}

?>

 

 

add this line to column_right.php :

 

include(DIR_WS_BOXES . 'order_order_history.php');

 

 

then you will have such a box, click on the order number takes you to order history of that order, click on the basket will execute the reorder function on that order.

Treasurer MFC

Link to comment
Share on other sites

well, you are missing the point.

 

that box shows the last product(s) the customer ordered and from that they can add that product to the cart. But normally you are always directed to the product page first if the product has attributes because only there you can set them.

 

The function "cust_order" does this and it has nothing to do with "reorder".

They are not executed in sequence but one at a time as separate called functions.

"cust_order" needs a product id.

"reorder" needs an order id.

 

So if you want to use reorder from a box on the index page, you need to create one that lists the last orders (not ordered products) and call the reorder function from there.

Thanks for your help, boxtel. I think I got it now. Always learn something new. Just wanted to make sure everything works properly.

 

Thanks again, :thumbsup:

Irina.

Link to comment
Share on other sites

  • 3 weeks later...

Dear Boxtel,

 

Thank you very much for writing this contribution. I would love to add it to my site but I don't know where to put it.

 

Could you let me know where to put it so customers can re-order from the order history page.

 

Thanks in advance,

gragra

Link to comment
Share on other sites

Dear Boxtel,

 

Thank you very much for writing this contribution.  I would love to add it to my site but I don't know where to put it.

 

Could you let me know where to put it so customers can re-order from the order history page.

 

Thanks in advance,

gragra

 

well, normally you have this code in account_history_info.php all the way at the bottom:

 

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, tep_get_all_get_params(array('order_id')), 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

 

 

you replace that with :

 

 

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, tep_get_all_get_params(array('order_id')), 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

<?php

echo tep_draw_form('order_update', tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $_GET['order_id'] . '&action=reorder'));

echo '<td valign="middle" align="right">' . tep_image_submit('button_in_cart.gif', 'Re-Order','','update_button') . '</td>';

echo '</form>';

?>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

Treasurer MFC

Link to comment
Share on other sites

well, normally you have this code in account_history_info.php all the way at the bottom:

 

                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

                <td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, tep_get_all_get_params(array('order_id')), 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

you replace that with :

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, tep_get_all_get_params(array('order_id')), 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

<?php

echo tep_draw_form('order_update', tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $_GET['order_id'] . '&action=reorder'));

echo '<td valign="middle" align="right">' . tep_image_submit('button_in_cart.gif', 'Re-Order','','update_button') . '</td>';

echo '</form>';

?>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

 

sorry, misread your request :

 

on account.php you simply change this:

 

 

<tr class="moduleRow" onMouseOver="rowOverEffect(this)" onMouseOut="rowOutEffect(this)" onClick="document.location.href='<?php echo tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL'); ?>'">

<td class="main" width="80"><?php echo tep_date_short($orders['date_purchased']); ?></td>

<td class="main"><?php echo '#' . $orders['orders_id']; ?></td>

<td class="main"><?php echo tep_output_string_protected($order_name) . ', ' . $order_country; ?></td>

<td class="main"><?php echo $orders['orders_status_name']; ?></td>

<td class="main" align="right"><?php echo $orders['order_total']; ?></td>

<td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL') . '">' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . '</a>'; ?></td>

</tr>

 

to this :

 

 

<tr class="moduleRow" onMouseOver="rowOverEffect(this)" onMouseOut="rowOutEffect(this)" onClick="document.location.href='<?php echo tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL'); ?>'">

<td class="main" width="80"><?php echo tep_date_short($orders['date_purchased']); ?></td>

<td class="main"><?php echo '#' . $orders['orders_id']; ?></td>

<td class="main"><?php echo tep_output_string_protected($order_name) . ', ' . $order_country; ?></td>

<td class="main"><?php echo $orders['orders_status_name']; ?></td>

<td class="main" align="right"><?php echo $orders['order_total']; ?></td>

<td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL') . '">' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . '</a>'; ?></td>

<td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'] . '&action=reorder', 'SSL') . '">' . tep_image_button('button_buy_now.gif', 'Reorder') . '</a>'; ?></td>

</tr>

 

 

and on account_history.php you change this :

 

 

<tr>

<td class="main" width="50%" valign="top"><?php echo '<b>' . TEXT_ORDER_DATE . '</b> ' . tep_date_long($history['date_purchased']) . '<br><b>' . $order_type . '</b> ' . tep_output_string_protected($order_name); ?></td>

<td class="main" width="30%" valign="top"><?php echo '<b>' . TEXT_ORDER_PRODUCTS . '</b> ' . $products['count'] . '<br><b>' . TEXT_ORDER_COST . '</b> ' . strip_tags($history['order_total']); ?></td>

<td class="main" width="20%"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'order_id=' . $history['orders_id'], 'SSL') . '">' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . '</a>'; ?></td>

</tr>

 

 

to this code :

 

<tr>

<td class="main" width="50%" valign="top"><?php echo '<b>' . TEXT_ORDER_DATE . '</b> ' . tep_date_long($history['date_purchased']) . '<br><b>' . $order_type . '</b> ' . tep_output_string_protected($order_name); ?></td>

<td class="main" width="30%" valign="top"><?php echo '<b>' . TEXT_ORDER_PRODUCTS . '</b> ' . $products['count'] . '<br><b>' . TEXT_ORDER_COST . '</b> ' . strip_tags($history['order_total']); ?></td>

<td class="main" width="20%"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'order_id=' . $history['orders_id'], 'SSL') . '">' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . '</a>'; ?></td>

<td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'] . '&action=reorder', 'SSL') . '">' . tep_image_button('button_buy_now.gif', 'Reorder') . '</a>'; ?></td>

</tr>

Treasurer MFC

Link to comment
Share on other sites

sorry, misread your request :

 

on account.php you simply change this:

                  <tr class="moduleRow" onMouseOver="rowOverEffect(this)" onMouseOut="rowOutEffect(this)" onClick="document.location.href='<?php echo tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL'); ?>'">

                    <td class="main" width="80"><?php echo tep_date_short($orders['date_purchased']); ?></td>

                    <td class="main"><?php echo '#' . $orders['orders_id']; ?></td>

                    <td class="main"><?php echo tep_output_string_protected($order_name) . ', ' . $order_country; ?></td>

                    <td class="main"><?php echo $orders['orders_status_name']; ?></td>

                    <td class="main" align="right"><?php echo $orders['order_total']; ?></td>

                    <td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL') . '">' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . '</a>'; ?></td>

                  </tr>

 

to this :

                  <tr class="moduleRow" onMouseOver="rowOverEffect(this)" onMouseOut="rowOutEffect(this)" onClick="document.location.href='<?php echo tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL'); ?>'">

                    <td class="main" width="80"><?php echo tep_date_short($orders['date_purchased']); ?></td>

                    <td class="main"><?php echo '#' . $orders['orders_id']; ?></td>

                    <td class="main"><?php echo tep_output_string_protected($order_name) . ', ' . $order_country; ?></td>

                    <td class="main"><?php echo $orders['orders_status_name']; ?></td>

                    <td class="main" align="right"><?php echo $orders['order_total']; ?></td>

                    <td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL') . '">' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . '</a>'; ?></td>

                    <td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'] . '&action=reorder', 'SSL') . '">' . tep_image_button('button_buy_now.gif', 'Reorder') . '</a>'; ?></td>

                  </tr>

and on account_history.php you change this :

                <tr>

                  <td class="main" width="50%" valign="top"><?php echo '<b>' . TEXT_ORDER_DATE . '</b> ' . tep_date_long($history['date_purchased']) . '<br><b>' . $order_type . '</b> ' . tep_output_string_protected($order_name); ?></td>

                  <td class="main" width="30%" valign="top"><?php echo '<b>' . TEXT_ORDER_PRODUCTS . '</b> ' . $products['count'] . '<br><b>' . TEXT_ORDER_COST . '</b> ' . strip_tags($history['order_total']); ?></td>

                  <td class="main" width="20%"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'order_id=' . $history['orders_id'], 'SSL') . '">' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . '</a>'; ?></td>

                </tr>

to this code :

 

                <tr>

                  <td class="main" width="50%" valign="top"><?php echo '<b>' . TEXT_ORDER_DATE . '</b> ' . tep_date_long($history['date_purchased']) . '<br><b>' . $order_type . '</b> ' . tep_output_string_protected($order_name); ?></td>

                  <td class="main" width="30%" valign="top"><?php echo '<b>' . TEXT_ORDER_PRODUCTS . '</b> ' . $products['count'] . '<br><b>' . TEXT_ORDER_COST . '</b> ' . strip_tags($history['order_total']); ?></td>

                  <td class="main" width="20%"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'order_id=' . $history['orders_id'], 'SSL') . '">' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . '</a>'; ?></td>

                  <td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'] . '&action=reorder', 'SSL') . '">' . tep_image_button('button_buy_now.gif', 'Reorder') . '</a>'; ?></td>

                </tr>

 

correction:

the last added column to account_history needs to read :

 

<td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $history['orders_id'] . '&action=reorder', 'SSL') . '">' . tep_image_button('button_buy_now.gif', 'Reorder') . '</a>'; ?></td>

 

as it needs to take the orders_id from the $history array.

Treasurer MFC

Link to comment
Share on other sites

correction:

the last added column to account_history needs to read :

 

                  <td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $history['orders_id'] . '&action=reorder', 'SSL') . '">' . tep_image_button('button_buy_now.gif', 'Reorder') . '</a>'; ?></td>

 

as it needs to take the orders_id from the $history array.

 

Dear Boxtel,

 

Thank you very much for replying. And for all your efforts explaining everything so well.

 

I did everything you said and it looks good, but when I press the "Add to Cart Button" the page refreshes but notthing gets added to the shopping cart. Do I need to add your contribution function somewhere as well? My guess is yes, but where?

 

Thanks again.

gragra

Link to comment
Share on other sites

Dear Boxtel,

 

Thank you very much for replying.  And for all your efforts explaining everything so well.

 

I did everything you said and it looks good, but when I press the "Add to Cart Button" the page refreshes but notthing gets added to the shopping cart.  Do I need to add your contribution function somewhere as well?  My guess is yes, but where?

 

Thanks again.

gragra

 

you only need that function once in general.php.

Treasurer MFC

Link to comment
Share on other sites

you only need that function once in general.php.

 

 

Thanks again Boxtel (Amanda), but I am still having trouble. I click on the add to cart from the account_history_info.php page and I just get a page refesh and the cary stays empty.

 

This is what I have done (luckily I found the instructions in your first submission).

 

In application_top.php I have added your case at the top above all the other cases, as below.

 

switch ($HTTP_GET_VARS['action']) {

 

// for order re-order function

case 'reorder' : $reorder_result = tep_reorder($_GET['order_id']);

if ($reorder_result == '') {

tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING));

}

break;

// end order-reorder function

 

 

 

In general.php I have inserted your latest submitted function (the most recent one on the contribution page) as the first function. I figure if I put your function in first, the computer won't miss it (computers work like this don't they? ha! ).

 

function tep_reorder ($orders_id) {

 

global $cart, $languages_id;

 

$result = '';

$ordered_products_query = tep_db_query("select op.products_id,

op.orders_products_id,

op.products_quantity,

p.products_status,

p.products_model,

p.products_quantity as stock,

pd.products_name

from " . TABLE_ORDERS_PRODUCTS . " op, " .

TABLE_PRODUCTS . " p, " .

TABLE_PRODUCTS_DESCRIPTION . " pd

where op.orders_id = '" . $orders_id . "' and

op.products_id = p.products_id and

p.products_id = pd.products_id and

pd.language_id = '" . $languages_id . "'");

 

while ($ordered_product = tep_db_fetch_array($ordered_products_query)) {

if ($ordered_product['products_status'] == '1') {

if (!tep_has_product_attributes($ordered_product['products_id'])) {

if ($ordered_product['stock'] >= ($cart->get_quantity($ordered_product['products_id'])+$ordered_product['products_quantity'])) {

$cart->add_cart($ordered_product['products_id'], $cart->get_quantity($ordered_product['products_id'])+$ordered_product['products_quantity']);

} else {

$result .= 'product: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Not enough stock<br>';

}

} else {

$attributes = array();

$attributes_count = 0;

$attributes_query = tep_db_query("select po.products_options_id ,

pov.products_options_values_id

from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " opa,

" . TABLE_PRODUCTS_OPTIONS . " po,

" . TABLE_PRODUCTS_OPTIONS_VALUES . " pov,

" . TABLE_PRODUCTS_ATTRIBUTES . " pa

where opa.orders_id = '" . $orders_id . "' and

opa.orders_products_id = '" . $ordered_product['orders_products_id'] . "' and

po.products_options_name = opa.products_options and

po.language_id = '" . $languages_id . "' and

pa.options_id = po.products_options_id and

pa.options_values_id = pov.products_options_values_id and

pa.products_id = '" . $ordered_product['products_id'] . "' and

pov.products_options_values_name = opa.products_options_values and

pov.language_id = '" . $languages_id . "'");

 

while ($attribute = tep_db_fetch_array($attributes_query)) {

$attributes[$attribute['products_options_id']] = $attribute['products_options_values_id'];

$attributes_count++;

}

 

if ($attributes_count < 1) {

$result .= 'product: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Attributes changed<br>';

}

 

if ($ordered_product['stock'] >= ($cart->get_quantity(tep_get_uprid($ordered_product['products_id'], $attributes))+$ordered_product['products_quantity'])) {

$cart->add_cart($ordered_product['products_id'], $cart->get_quantity(tep_get_uprid($ordered_product['products_id'], $attributes))+$ordered_product['products_quantity'], $attributes);

} else {

$result .= 'product: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Not enough stock (attr)<br>';

}

}

} else {

$result .= 'product: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Not Available<br>';

}

}

return $result;

}

 

//end order re order function

 

 

 

 

 

 

And in account_history_info.tpl.php I have added what you said to make the add to cart button display etc.

 

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, tep_get_all_get_params(array('order_id')), 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

<?php

echo tep_draw_form('order_update', tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $_GET['order_id'] . '&action=reorder'));

echo '<td valign="middle" align="right">' . tep_image_submit('button_in_cart.gif', 'Re-Order','','update_button') . '</td>';

echo '</form>';

?>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

 

 

 

Are you able to see from this what I have missed? Thanks if you are able to give me any tips.

 

Best wishes,

gragra

Link to comment
Share on other sites

Dear Boxtel,

 

I tried your first submitted function (put it into general.php) and it worked well but only copied the first two items into the cart from the previous order, but not any more than this if there are more items.

I then put the more recent one into general.php and it went back to not working again.

 

So I hope this information helps....

 

Best wishes, Gragra

Link to comment
Share on other sites

Dear Boxtel,

 

I tried your first submitted function (put it into general.php) and it worked well but only copied the first two items into the cart from the previous order, but not any more than this if there are more items.

I then put the more recent one into general.php and it went back to not working again.

 

So I hope this information helps....

 

Best wishes, Gragra

 

 

try replacing the code in application_top.php with this:

 

switch ($HTTP_GET_VARS['action']) {

 

// for order re-order function

case 'reorder' : $reorder_result = tep_reorder($_GET['order_id']);

if ($reorder_result == '') {

tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING));

} else {

echo $reorder_result; // print results if not all products added

}

break;

// end order-reorder function

 

 

this will print out the results of the reorder function on the top of your screen if not all products were added.

Later you could add that text into your message stack or in a popup which looks better than at the top of the screen.

Treasurer MFC

Link to comment
Share on other sites

Thank you Boxtel,

The problem was that the non-added products were not in stock and this was preventing them from being added.

Thanks for your contribution and for your support.

Best wishes, Gragra

Link to comment
Share on other sites

  • 3 weeks later...

Thanks for this excellent contribution! I have been looking for something like this for quite some time. I just had a couple tweeks to add to this contribution.

 

includes/application_top.php

change

case 'reorder' : $reorder_result = tep_reorder($_GET['order_id']);

 

to

case 'reorder' : $reorder_result = tep_reorder($HTTP_GET_VARS['order_id']);

 

 

This alteration will allow search engine safe urls to work. The contribution wasn't working for me until I turned off search engine safe urls; but with this change it functions properly.

 

 

includes/functions/general.php

change

        if ($ordered_product['stock'] >= ($cart->get_quantity($ordered_product['products_id'])+$ordered_product['products_quantity'])) {

 

to

        if (($ordered_product['stock'] >= ($cart->get_quantity($ordered_product['products_id'])+$ordered_product['products_quantity'])) || STOCK_ALLOW_CHECKOUT == "true") {

 

and change

          if ($ordered_product['stock'] >= ($cart->get_quantity(tep_get_uprid($ordered_product['products_id'], $attributes))+$ordered_product['products_quantity'])) {

 

to

          if (($ordered_product['stock'] >= ($cart->get_quantity(tep_get_uprid($ordered_product['products_id'], $attributes))+$ordered_product['products_quantity'])) || STOCK_ALLOW_CHECKOUT == "true") {

 

If your store is like mine, you don't keep track of product quantity. The contribution will now check to see if you want to check stock level for product (admin > configuration > stock > check stock level : true/false)

 

 

Again thanks for this great contribution!!!

Link to comment
Share on other sites

  • 2 months later...
Hi,

Can you explain me step by step how to install this contribution? I'am not good in php but I want to learn. PS sory for my english

 

greatz 4 all

matheush from POLAND

 

well, the instructions are in the contribution itself.

 

it is basically a function which you can call from anywhere, give it an order_id and it will add the same contents to the shopping cart with attributes if present.

Treasurer MFC

Link to comment
Share on other sites

  • 2 weeks later...

Has anyone gotten this to work with Option Type - Feature contrib.

 

(Text attributes)

 

I'm trying to work through the function to figure out a way to grab the text from the last order as the option value, but i'm just missing it somewhere.

Link to comment
Share on other sites

  • 1 month later...

Anyone figured out a way to send them directly to the shopping cart screen after they reorder a previous order (instead of going right into the checkout procedure?)

 

I need the customer to be able to change the quantity of products..

Link to comment
Share on other sites

Anyone figured out a way to send them directly to the shopping cart screen after they reorder a previous order (instead of going right into the checkout procedure?)

 

I need the customer to be able to change the quantity of products..

 

tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING));

 

->

 

tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));

Treasurer MFC

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...