Zen Cart Logo
Forums / Managing Customers and Orders / Need some development logic opinions

Need some development logic opinions

Locked

Views: 940

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
20 Oct 2010, 1:52 AM
#1
buckit avatar

buckit

New Zenner

Join Date:
Nov 2009
Posts:
45
Plugin Contributions:
0

Need some development logic opinions

I have sell "high risk" items online... only 2 categories are considered "high risk" and accounts for about half of my products.

the problem is I only have 1 CC processor that allows me to process CCs for the products I sell. that 1 processor (payment alliance) will doesn't put the money in my account for 3-5 days. That means I have to float the cash for that long. considering the fast growth of my store and the fact that I did this with ZERO loans, cash-flow is becoming an issue.

The processor from my bank (PNC) will put money in my account next day! This would be HUGE for me. problem is they wont allow me to process the "high risk" items. but they will allow me to process the other 16,000 items (which account for 85% of all orders).

so, I need to use 2 different payment processors based on what the customer is purchasing.

here are my 2 ideas to overcome this:

  1. create 2 completely separate sites that share a database (each site using a different table prefix) then edit the code so the customer and order tables are shared between the 2 sites (remove table prefix reference in the code). this way user accounts and orders will all be maintained in one location. customers can see all their orders no matter which site they are in and they have 1 login for both sites.

  2. edit the checkout pages to use a 1 payment module if it has a "high risk" item in the cart and use the other if it doesn't.

as a developer I am very familiar with zen carts template system and have done an extensive amount of editing in the code... so I am not a noob getting in over his head! but I will admit that I haven't messed with the payment modules to much extent yet. but I am confident in being able to complete either option with enough time and research.

so... zen developers... which route would you go? option 1 or option 2? or maybe a 3rd I havent thought of?

20 Oct 2010, 2:13 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Need some development logic opinions

Are the High Risk items all in the same Category or in a handful of Categories that do not include the Regular Products?

The idea here is that if the High Risk Products use particular msater_categories_id that the other Regular Products do not, then this can be tested for and if 1 or more High Risk Product is in the cart ... then only use the 1 Payment module and if no High Risk Product is in the Cart ... then use the other Payment Module ...

20 Oct 2010, 3:15 AM
#3
buckit avatar

buckit

New Zenner

Join Date:
Nov 2009
Posts:
45
Plugin Contributions:
0

Re: Need some development logic opinions

Ajeh:

Are the High Risk items all in the same Category or in a handful of Categories that do not include the Regular Products?

The idea here is that if the High Risk Products use particular msater_categories_id that the other Regular Products do not, then this can be tested for and if 1 or more High Risk Product is in the cart ... then only use the 1 Payment module and if no High Risk Product is in the Cart ... then use the other Payment Module ...

yes. all high risk products are in their own category. i already have a check in place on the first checkout page to display a procedures notification if an item from high risk category is in cart.

now the oyher thing is the payment gateways will need tobse the same module. so i guess i can just edit the payment module with a statement that will change te unique data (login id and hash stuff) based on what category thebitems in the cart are from.

thats probably a much better/easier idea considering it would only need 1 file to be edited.

20 Oct 2010, 4:00 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Need some development logic opinions

By being able to identify these products by master_categories_id this can be used to enable on module and disable the other and visa versa ...

20 Oct 2010, 1:14 PM
#5
buckit avatar

buckit

New Zenner

Join Date:
Nov 2009
Posts:
45
Plugin Contributions:
0

Re: Need some development logic opinions

Ajeh:

By being able to identify these products by master_categories_id this can be used to enable on module and disable the other and visa versa ...

wait... you're in ohio? me too! :)

I'll start researching how the payment/checkout works and see if I can work this out. want to give any hints as to what files to start looking at? :)

20 Oct 2010, 1:39 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Need some development logic opinions

What you are looking for is the $this->enabled ...

When set to true it will show and when set to false it will not show ...

if you search on:
$this->enabled

you should find several examples of how this can be altered for true/false by various tests for the cart contents ...

25 Oct 2010, 4:37 PM
#7
buckit avatar

buckit

New Zenner

Join Date:
Nov 2009
Posts:
45
Plugin Contributions:
0

Re: Need some development logic opinions

I have it all figured out... thanks again for your help!

one question... is there a better way of doing the following:

foreach ($order->products as $k => $v) {
	if(zen_get_categories_parent_name(zen_get_products_category_id($order->products[$k]['id'])) == 'the top category name'){
		do something;
	}
}

the biggest problem with this is if the the tree is more than 1 level deep it wont return the top level category only the product categories parent.

is there a function to get the top level category? or to atleast get the parrent ID? I couldnt seem to find one.

I can write one... but would rather use built in stuff if at all possible:

  function zen_categories_top_level($categories_id){
	  $lookup = 1;
	  while($lookup != 0){
		$lookup = zen_categories_lookup($categories_id,'parent_id');
		if($lookup != 0){
			$categories_id = $lookup;
		}
	  }
	  return $categories_id;
  }
25 Oct 2010, 5:34 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Need some development logic opinions

You could try:
(int)zen_get_generated_category_path_rev($current_category_id)

which would give the top based on the $current_category_id, so if you passed it a specific Category ID such as:
(int)zen_get_generated_category_path_rev(40)

where the cPath is 33_34_40 and the top level was 33, it would find 33 ...