Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

defender39

Archived
  • Posts

    397
  • Joined

  • Last visited

Profile Information

defender39's Achievements

  1. Ok I think I have it. ? ? if ($get_result['restrict_to_products']) { ? ? ? $pr_ids = split("[,]", $get_result['restrict_to_products']); ? ? ? $in_cart=false; ? ? ? $products_array = $cart->get_products(); // ? ? ? for ($i = 0; $i < sizeof($pr_ids); $i++) { // ? ? ? ? for ($ii = 1; $ii<=sizeof($products_array); $ii++) { // ? ? ? ? ? if (tep_get_prid($products_array[$ii-1]['id']) == $pr_ids[$i]) { // ? ? ? ? ? ? $in_cart=true; ? ? ? ? ? ? ? $total_price += $order_total; // ? ? ? ? ? } // ? ? ? ? } // ? ? ? } ? ? ? $order_total = $total_price; ? ? ? ? ? ? } ? } ? return $order_total; ?} ? I commented out the lines that add up the products. Then I changed ? ? ? ? ? ? $total_price += $this->get_product_price($products_array[$ii-1]['id']); to: $total_price += $order_total; I guess that's about as clean as I can make it. It seems to work as I want and I tested against a few things and it seems ok.
  2. I just read as much as I can here and didnt find one thing that I just realized is a problem. When you restrict a coupon to a product or category...but then decide on a minimum...It actually only seems to check the total of the valid products to reach the minimum of the coupon. This shouldn't be. Lets say I have X item valid and its a $10 item but I want the coupon to have a $30 minimum to reach that deal...well it only sees the $10 total and wont allow the coupon to work even if I have $50 worth in my cart. If I wanted to make only the valid product or category a $10 minimum than I would set that. I been looking at the code for a couple hours and cant seem to get it right. ? // OK thats fine for global coupons but what about restricted coupons ? ?// where you can only redeem against certain products/categories. ? ?// and I though this was going to be easy !!! ? $coupon_query=tep_db_query("select coupon_code ?from " . TABLE_COUPONS . " where coupon_id='".$cc_id."'"); ? if (tep_db_num_rows($coupon_query) !=0) { ? ? $coupon_result=tep_db_fetch_array($coupon_query); ? ? $coupon_get=tep_db_query("select coupon_amount, coupon_minimum_order,restrict_to_products,restrict_to_categories, coupon_type from " . TABLE_COUPONS . " where coupon_code='".$coupon_result['coupon_code']."'"); ? ? $get_result=tep_db_fetch_array($coupon_get); ? ? $in_cat = true; ? ? if ($get_result['restrict_to_categories']) { ? ? ? $cat_ids = split("[,]", $get_result['restrict_to_categories']); ? ? ? $in_cat=false; ? ? ? for ($i = 0; $i < count($cat_ids); $i++) { ? ? ? ? if (is_array($this->contents)) { ? ? ? ? ? reset($this->contents); ? ? ? ? ? while (list($products_id, ) = each($this->contents)) { ? ? ? ? ? ?$cat_query = tep_db_query("select products_id from products_to_categories where products_id = '" . $products_id . "' and categories_id = '" . $cat_ids[$i] . "'"); ? ? ? ? ? ? if (tep_db_num_rows($cat_query) !=0 ) { ? ? ? ? ? ? ? $in_cat = true; ? ? ? ? ? ? ? $total_price += $this->get_product_price($products_id); ? ? ? ? ? ? } ? ? ? ? ? } ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? ? } ? ? $in_cart = true; ? ? if ($get_result['restrict_to_products']) { ? ? ? $pr_ids = split("[,]", $get_result['restrict_to_products']); ? ? ? $in_cart=false; ? ? ? $products_array = $cart->get_products(); ? ? ? for ($i = 0; $i < sizeof($pr_ids); $i++) { ? ? ? ? for ($ii = 1; $ii<=sizeof($products_array); $ii++) { ? ? ? ? ? if (tep_get_prid($products_array[$ii-1]['id']) == $pr_ids[$i]) { ? ? ? ? ? ? $in_cart=true; ? ? ? ? ? ? $total_price += $this->get_product_price($products_array[$ii-1]['id']); ? ? ? ? ? } ? ? ? ? } ? ? ? } ? ? ? $order_total = $total_price; ? ? ? ? ? ? } ? } ? return $order_total; ?} ? It is most likely here but I havent found out yet how to correct this. Please Please Please help me out.
  3. That's not working for me. I am on MS1... I keep getting really close but there is always something not working right. This is the closest I got now. echo '<tr><td>'; $sort_array = array(); $sort_array = array(); $sort_array[] = array('id' => '4a', 'text' => 'Product Name Ascending'); $sort_array[] = array('id' => '4d', 'text' => 'Product Name Descending'); $sort_array[] = array('id' => '3a', 'text' => 'Product Price Ascending'); $sort_array[] = array('id' => '3d', 'text' => 'Product Price Descending'); echo tep_draw_form('sort', '', 'post'); echo tep_draw_pull_down_menu('sort', $sort_array, (isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : ''), 'onChange="this.form.submit();"'); echo '</form></td></tr>'; I added this to my index.php but I am using SEF urls. So lets say I am here: http://www.videogamedeals.com/index.php/so...th/87_19/page/2 Well when I make a change it makes the url this: http://www.videogamedeals.com/index.php/so.../page/2?sort=4d As you can see it quickly starts to make a mess of the url. So does anyone know how I might correct this?
  4. My latest attempt is much better: <tr> <td> <?php echo tep_draw_form('sort', '', 'post'); echo tep_draw_pull_down_menu('sort', array(array('id' => '3a', 'text' => 'Name'), array('id' => '4d', 'text' => 'Sort by Price')), '', 'onchange="this.form.submit()"'); ?> </form> </td> </tr> While this now submits the page doesnt actually work. I have the sort options correct as 3a and 4d to try to force results but neither seems to take. Hmm..any new ideas? Once this is fixed up some it can be added to the contrib so that others who use column display can have more sort options.
  5. OK well this is what I have that's working now as a drop down menu. <tr> <td> <?php echo tep_draw_pull_down_menu('sort', array(array('id' => 'ALA', 'text' => 'ALA'), array('id' => 'Price', 'text' => 'Sort by Price')), 'Price'); ?> </td> </tr> the problem is that I am unable to get it to submit onchange. Do I have to create a tep_draw_form?
  6. Here is what I have but it just uses the first letter. I know I am not even close to getting this correct. <tr> <td> <?php $sort = array( 'price', 'date', 'name', ); echo tep_draw_pull_down_menu('sort', $sort,'',''); ?> </td> </tr>
  7. I have been using a product_listing_col.php instead of the rows listing and I like it's look but I recently noticed that you cannot sort by price or stock. With the regular product_listing.php module you get a header with sort option. I want to create a dropdown menu with sort options but I am having an impossible time trying to create a tep_draw_drop_down_menu with the proper array. My array is always empty. I havent written an array from scratch and all my attempts using examples from php.net still create an empty drop down list. Can someone give me a hand on this one? Here is the original contrib I am using. http://www.oscommerce.com/community/contributions,112
  8. I believe the auto thumb generator works with the tep_image function so if you removed that function for the header image call then the auto thumb generator will just leave it alone. You are basically hard coding the image. If it's just one image this will work just fine.
  9. you can set the default higher in the admin...if 10 is too low then make it 20, 25 or whatever you think works
  10. http://www.oscommerce.com/community/contributions,2093 Quick and easy to install... ifyou have any questions please feel free to post. This just does the MYsql optimize command to your OSC database. This can help keep your site error free and even load faster.
  11. User has been helped...her file got corrupted and cut off...
  12. Here is what I have so far: class ot_coupon { var $title, $output; function ot_coupon() { $this->code = 'ot_coupon'; $this->header = MODULE_ORDER_TOTAL_COUPON_HEADER; $this->title = MODULE_ORDER_TOTAL_COUPON_TITLE; $this->description = MODULE_ORDER_TOTAL_COUPON_DESCRIPTION; $this->user_prompt = ''; $this->enabled = MODULE_ORDER_TOTAL_COUPON_STATUS; $this->sort_order = MODULE_ORDER_TOTAL_COUPON_SORT_ORDER; $this->include_shipping = MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING; $this->include_tax = MODULE_ORDER_TOTAL_COUPON_INC_TAX; $this->calculate_tax = MODULE_ORDER_TOTAL_COUPON_CALC_TAX; $this->tax_class = MODULE_ORDER_TOTAL_COUPON_TAX_CLASS; $this->credit_class = true; $this->output = array(); } function process() { global $order, $currencies; $order_total=$this->get_order_total(); $od_amount = $this->calculate_credit($order_total); $this->deduction = $od_amount; if ($this->calculate_tax != 'none') { $tod_amount = $this->calculate_tax_deduction($order_total, $this->deduction, $this->calculate_tax); } if ($od_amount > 0) { $order->info['total'] = $order->info['total'] - $od_amount; $this->output[] = array('title' => $this->title . ':' . $this->coupon_code .':', 'text' => '<b>' . $currencies->format($od_amount) . '</b>', 'value' => $od_amount); } } function selection_test() { return false; } function pre_confirmation_check($order_total) { global $customer_id; return $this->calculate_credit($order_total); } function use_credit_amount() { return $output_string; } function credit_selection() { global $customer_id, $currencies, $language; $selection_string = ''; $selection_string .= '<tr>' . "\n"; $selection_string .= ' <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>'; $selection_string .= ' <td class="main">' . "\n"; $image_submit = '<input type="image" name="submit_redeem" onClick="submitFunction()" src="' . DIR_WS_LANGUAGES . $language . '/images/buttons/button_redeem.gif" border="0" alt="' . IMAGE_REDEEM_VOUCHER . '" title = "' . IMAGE_REDEEM_VOUCHER . '">'; $selection_string .= TEXT_ENTER_COUPON_CODE . tep_draw_input_field('gv_redeem_code') . '</td>'; $selection_string .= ' <td align="right"' . $image_submit . '</td>'; $selection_string .= ' <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>'; $selection_string .= '</tr>' . "\n"; return $selection_string; } function collect_posts() { global $HTTP_POST_VARS, $customer_id, $currencies, $cc_id; if ($HTTP_POST_VARS['gv_redeem_code']) { // get some info from the coupon table $coupon_query=tep_db_query("select coupon_id, coupon_amount, coupon_type,coupon_ship_type, coupon_minimum_order, uses_per_coupon, uses_per_user, restrict_to_products, restrict_to_categories from " . TABLE_COUPONS . " where coupon_code='".$HTTP_POST_VARS['gv_redeem_code']."' and coupon_active='Y'"); $coupon_result=tep_db_fetch_array($coupon_query); if ($coupon_result['coupon_type'] != 'G') { if (tep_db_num_rows($coupon_query)==0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_INVALID_REDEEM_COUPON), 'SSL')); } $date_query=tep_db_query("select coupon_start_date from " . TABLE_COUPONS . " where coupon_start_date <= now() and coupon_code='".$HTTP_POST_VARS['gv_redeem_code']."'"); if (tep_db_num_rows($date_query)==0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_INVALID_STARTDATE_COUPON), 'SSL')); } $date_query=tep_db_query("select coupon_expire_date from " . TABLE_COUPONS . " where coupon_expire_date >= now() and coupon_code='".$HTTP_POST_VARS['gv_redeem_code']."'"); if (tep_db_num_rows($date_query)==0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_INVALID_FINISDATE_COUPON), 'SSL')); } $coupon_count = tep_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $coupon_result['coupon_id']."'"); $coupon_count_customer = tep_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $coupon_result['coupon_id']."' and customer_id = '" . $customer_id . "'"); if (tep_db_num_rows($coupon_count)>=$coupon_result['uses_per_coupon'] && $coupon_result['uses_per_coupon'] > 0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_INVALID_USES_COUPON . $coupon_result['uses_per_coupon'] . TIMES ), 'SSL')); } if (tep_db_num_rows($coupon_count_customer)>=$coupon_result['uses_per_user'] && $coupon_result['uses_per_user'] > 0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_INVALID_USES_USER_COUPON . $coupon_result['uses_per_user'] . TIMES ), 'SSL')); } if ($coupon_result['coupon_type']=='S' && $coupon_result['coupon_ship_type']=='Flat Rate USA ONLY') { $coupon_amount = $order->info['shipping_cost']; } else { $coupon_amount = $currencies->format($coupon_result['coupon_amount']) . ' '; } if ($coupon_result['type']=='P') $coupon_amount = $coupon_result['coupon_amount'] . '% '; if ($coupon_result['coupon_minimum_order']>0) $coupon_amount .= 'on orders greater than ' . $coupon_result['coupon_minimum_order']; // if (!tep_session_is_registered('cc_id')) tep_session_register('cc_id'); $_SESSION['cc_id'] = $coupon_result['coupon_id']; } if ($HTTP_POST_VARS['submit_redeem_coupon_x'] && !$HTTP_POST_VARS['gv_redeem_code']) tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_REDEEM_CODE), 'SSL')); } } function calculate_credit($amount) { global $customer_id, $order, $cc_id; $cc_id = $_SESSION['cc_id']; $od_amount = 0; if ($cc_id) { $coupon_query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . $cc_id . "'"); if (tep_db_num_rows($coupon_query) !=0 ) { $coupon_result = tep_db_fetch_array($coupon_query); $this->coupon_code = $coupon_result['coupon_code']; $coupon_get = tep_db_query("select coupon_amount, coupon_minimum_order, restrict_to_products, restrict_to_categories, coupon_type from " . TABLE_COUPONS ." where coupon_code = '". $coupon_result['coupon_code'] . "'"); $get_result = tep_db_fetch_array($coupon_get); $c_deduct = $get_result['coupon_amount']; if ($get_result['coupon_type']=='S' && $coupon_result['coupon_ship_type']=='Flat Rate USA ONLY') $c_deduct = $order->info['shipping_cost']; if ($get_result['coupon_minimum_order'] <= $this->get_order_total()) { if ($get_result['restrict_to_products'] || $get_result['restrict_to_categories']) { for ($i=0; $i<sizeof($order->products); $i++) { if ($get_result['restrict_to_products']) { $pr_ids = split("[,]", $get_result['restrict_to_products']); for ($ii = 0; $ii < count($pr_ids); $ii++) { if ($pr_ids[$ii] == tep_get_prid($order->products[$i]['id'])) { if ($get_result['type'] == 'P') { $od_amount = round($amount*10)/10*$c_deduct/100; $pr_c = $order->products[$i]['final_price']*$order->products[$i]['qty']; $pod_amount = round($pr_c*10)/10*$c_deduct/100; } else { $od_amount = $c_deduct; } } } } else { $cat_ids = split("[,]", $get_result['restrict_to_categories']); for ($i=0; $i<sizeof($order->products); $i++) { $my_path = tep_get_product_path(tep_get_prid($order->products[$i]['id'])); $sub_cat_ids = split("[_]", $my_path); for ($iii = 0; $iii < count($sub_cat_ids); $iii++) { for ($ii = 0; $ii < count($cat_ids); $ii++) { if ($sub_cat_ids[$iii] == $cat_ids[$ii]) { if ($get_result['coupon_type'] == 'P') { $od_amount = round($amount*10)/10*$c_deduct/100; $pr_c = $order->products[$i]['final_price']*$order->products[$i]['qty']; $pod_amount = round($pr_c*10)/10*$c_deduct/100; } else { $od_amount = $c_deduct; } } } } } } } } else { if ($get_result['coupon_type'] !='P') { $od_amount = $c_deduct; } else { $od_amount = $amount * $get_result['coupon_amount'] / 100; } } } } if ($od_amount>$amount) $od_amount = $amount; } return $od_amount; } function calculate_tax_deduction($amount, $od_amount, $method) { global $customer_id, $order, $cc_id, $cart; $cc_id = $_SESSION['cc_id']; $coupon_query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . $cc_id . "'"); if (tep_db_num_rows($coupon_query) !=0 ) { $coupon_result = tep_db_fetch_array($coupon_query); $coupon_get = tep_db_query("select coupon_amount, coupon_minimum_order, restrict_to_products, restrict_to_categories, coupon_type from " . TABLE_COUPONS . " where coupon_code = '". $coupon_result['coupon_code'] . "'"); $get_result = tep_db_fetch_array($coupon_get); if ($get_result['coupon_type'] != 'S') { if ($get_result['restrict_to_products'] || $get_result['restrict_to_categories']) { // What to do here. // Loop through all products and build a list of all product_ids, price, tax class // at the same time create total net amount. // then // for percentage discounts. simply reduce tax group per product by discount percentage // or // for fixed payment amount // calculate ratio based on total net // for each product reduce tax group per product by ratio amount. $products = $cart->get_products(); for ($i=0; $i<sizeof($products); $i++) { $t_prid = tep_get_prid($products[$i]['id']); $cc_query = tep_db_query("select products_tax_class_id from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'"); $cc_result = tep_db_fetch_array($cc_query); $valid_product = false; if ($get_result['restrict_to_products']) { $pr_ids = split("[,]", $get_result['restrict_to_products']); for ($p = 0; $p < sizeof($pr_ids); $p++) { if ($pr_ids[$p] == $t_prid) $valid_product = true; } } if ($get_result['restrict_to_categories']) { $cat_ids = split("[,]", $get_result['restrict_to_categories']); for ($c = 0; $c < sizeof($cat_ids); $c++) { $cat_query = tep_db_query("select products_id from products_to_categories where products_id = '" . $products_id . "' and categories_id = '" . $cat_ids[$i] . "'"); if (tep_db_num_rows($cat_query) !=0 ) $valid_product = true; } } if ($valid_product) { $valid_array[] = array('product_id' => $t_prid, 'products_price' => $products[$i]['final_price'] * $products[$i]['quantity'], 'products_tax_class' => $cc_result['products_tax_class_id']); $total_price += $products[$i]['final_price'] * $products[$i]['quantity']; } } if ($valid_product) { if ($get_result['coupon_type'] == 'P') { $ratio = $get_result['coupon_amount']/100; } else { $ratio = $od_amount / $total_price; } if ($get_result['coupon_type'] == 'S') $ratio = 1; if ($method=='Credit Note') { $tax_rate = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $tax_desc = tep_get_tax_description($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); if ($get_result['coupon_type'] == 'P') { $tod_amount = $od_amount / (100 + $tax_rate)* $tax_rate; } else { $tod_amount = $order->info['tax_groups'][$tax_desc] * $od_amount/100; } $order->info['tax_groups'][$tax_desc] -= $tod_amount; $order->info['total'] -= $tod_amount; } else { I added to my DB a field called coupon_ship_type and its set for my flat rate shipping. I added coupon_ship_type to the $coupon_results string now as you can see I tried this: if ($coupon_result['coupon_type']=='S' && $coupon_result['coupon_ship_type']=='Flat Rate USA ONLY') { $coupon_amount = $order->info['shipping_cost']; } else { $coupon_amount = $currencies->format($coupon_result['coupon_amount']) . ' '; no luck though...
  13. Ok...I am looking at ot_coupon.php and I think this is really possible to make the free shipping force to only a certain type. Just like the other if options for the coupon uses. I want to start by making sure that I can hard code the ot_coupon.php before I modify my admin side and the DB tables. I see this line about 4 times in ot_coupon.php if ($get_result['coupon_type'] != 'S') { I would believe it can be altered to something like if ($get_result['coupon_type'] != 'S' && SHIPPING_CHOICE='cheapest shipping') { So far I am not sure how I can get ot_coupon.php to read the SHIPPING_CHOICE any help in this would be great...I will continue to try do this myself but so far no luck so my question at this point is simple. How can I get ot_coupon.php to read the shipping_method variable? I see in ot_shipping.php this $order->info['shipping_method'] but it doesnt seem to take effect if I add that to coupon.
  14. I also really need to make free shipping available to a specific shipping option. I am having serious problems with free shipping coupons and people selecting $100 overnight shipping and thats not acceptable. I need to be able to select in admin the shipping module that the free shipping coupon is good for. The coupon should error out if another selection is made. This would be great and any help in the code would be awesome.
  15. what about images? It would be nice if a bundled product displayed the image from each of the items included...
×
×
  • Create New...