Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Variable Text Needed in checkout_shipping.php


wolfmann999

Recommended Posts

Posted

Hi,

 

I need to change the text the appears within the checkout_shipping.php page if the customer has selected, and placed in the shopping basket, a specific product or a product from a specific category.

 

How can I test, for example, against a category id of 66 or a product id of 844 that would currently reside within the shopping basket, on the checkout_shipping.php page.

 

Any help much appreciated.

 

Wolfmann

Posted

Nick,

 

Why would you need to check Category ID or Product ID once the item is in the cart? Stock is controlled from admin (whether or not you have it set to monitor stock) so what would be the benefit of checking those variables? I guess I don't understand the reason for it.

 

 

Chris

  • 2 weeks later...
Posted

Hi Chris,

 

I need to check so that I can change the text that appears on the checkout_shipping page. If a product, from a certain category, exists in the shopping basket I need to show a warning message to the customer before purchase.

 

So far I have cobbled together the following, but I an not sure if my syntax is correct??

 

$orders_products_query = tep_db_query("select count(*) amount from products_to_categories p, " . TABLE_ORDERS_PRODUCTS . " t where p.categories_id = '80' and t.products_id = p.products_id and t.orders_id = '" . (int)$order_id . "'");
global $repairflag;

if (tep_db_num_rows($orders_products_query) > 0) {
       $repairflag = 1;}

 

Any help much appreciated,

 

Nick.

Posted

I tested this and it seemed to work.

 

At the top of /catalog/checkout_shipping.php change this code:

 

  require('includes/application_top.php');
 require('includes/classes/http_client.php');

 

To:

 

  require('includes/application_top.php');
 require('includes/classes/http_client.php');

 function prod_in_cart( $target_category ) {
   global $cart;
   if ($cart->count_contents() > 0) {
     $products = $cart->get_products();
     for ($i=0, $n=sizeof($products); $i<$n; $i++) {
       $path = tep_get_product_path( $products[$i]['id'] );
       $pieces = explode("_", $path);
       if ( ( count($pieces) ) && ( $target_category == $pieces[0] ) )
         return true;
     }
     return false;
   } else
     return false;
 }

 

Then where you want to check and display a warning the code would go something like this:

 

<?php
 if ( prod_in_cart( '21' ) ) {
?>
******** DELETE THIS LINE AND INSERT THE WARNING MESSAGE ********
<?php
 }
?>

 

I used category '21' as an example. Change it to YOUR category number you want to check.

 

The code doesn't check sub-categories, just main categories.

 

As always backup the file before making any edits.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Archived

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

×
×
  • Create New...