Creating A New Payment Category For 3Rd Party Finance Form?

So I'm trying to integrate V12 finance like in my old cart. I'm almost there with the basic script to pass on hidden form variables, however need to configure a customer front end form to allow the customer to select available finance options etc.



I am thinking I copy cc.tpl and adjust it, but I need this to be displayed in a separate payment category right?

OK Maybe this will work in one of the 3 existing categories. The main issue I have now is I need the order value available in PHP in the processor_template to restrict the finance options in the form drop down.



How can i call and print the order total here? From there I should be able to work the rest out…

The database entry for the payment method has a column for the template to use. So instead of cc.tpl name it V12.tpl. Copy cc.tpl to V12.tpl and then make whatever modifications you want.

The template used has nothing to do with what payment category you put the method under.

Thanks - managed that last night. But is there a way to get the order value as a variable to determine available drop down options by if statements herein this .tpl file?

Note that it will be required to change template in two tables:


  • cscart_payments
  • cscart_payment_processors

Yes I did that thanks (for the user and admin).



Question is can I execute PHP here and access the order total value?

[quote name='amdowney' timestamp='1423145699' post='204404']

Yes I did that thanks (for the user and admin).



Question is can I execute PHP here and access the order total value?

[/quote]



Use {$smarty.session.cart.total} in the template

For order info, as Ecom stated above.


[quote]Question is can I execute PHP here and access the order total value?[/quote]

You can execute php functions as smarty variable modifiers. Do a Google search for “smarty variable modifiers” to get to the documentation that gives you the syntax. But essentially, to call something like str_replace($pat, $rep, $src) you would use something like:


{"my pattern"|str_replace:"replace with":$smarty_variable}




But it should be rare to call php code from templates. The correct way is to determine in the controller ('checkout.checkout' in this case) and then set a smarty variable that can be referenced in your script in a post controller like app/addons/my_changes/controllers/frontend/checkout.post.php.

Thanks, big help! I literally just need to order total to determine select box options. Although the only other thing, is there a way also to determine if a sale product is in the basket (item price is lower than list price) at the same point? As again this will restrict choice…



Been familiar with PhP for years but this is all new!

Not that I know of from the 'cart'. You would have to query the DB for each product to determine if list is greater than price. Note too that any promotion or option-modifier could affect price and would not necessarily give you accurate info.



It is always BEST to keep business logic out of the templates. I.e. use the PHP controllers to add attributes into the cart product at the time they are placed to indicate if price is less than list. Then just look for products with the attribute set or with whatever value you want to look at in it.

OK, guess I'll have to come back to that bit, for now about to test:

```php

{$mindep = $smarty.session.cart.total * 0.1 }


Finance option

{if $smarty.session.cart.total > 2000}


Interest Free Finance (6 Months)
Interest Free Finance (12 Months)
Interest Free Finance (18 Months)
Interest Free Finance (24 Months)
Interest Free Finance (36 Months)
{elseif $smarty.session.cart.total > 1000}

Interest Free Finance (6 Months)
Interest Free Finance (12 Months)
Interest Free Finance (18 Months)
Interest Free Finance (24 Months)
{elseif $smarty.session.cart.total > 600}

Interest Free Finance (6 Months)
Interest Free Finance (12 Months)
Interest Free Finance (18 Months)
{elseif $smarty.session.cart.total > 300}

Interest Free Finance (6 Months)
Interest Free Finance (12 Months)

{/if}



Deposit (10% minimum)



```

Hmm. the DP and PID variables are not being passed through?

[quote name='amdowney' timestamp='1423231779' post='204526']

Hmm. the DP and PID variables are not being passed through?

[/quote]



If you want them to be displayed in the same way as for default payment methods, please use




Thanks, that did the trick, the relevant info gets passed through to the gateway (just have to work on he call back next).



More importantly I need to have in the product details display an example of a finance option being displayed based on the product price. Again I managed this in the old cart but am confused as to where to look at implementing this. In product_templates/default_template.tpl and amongst/after the following:





{assign var=“old_price” value=“old_price_$obj_id”}

{assign var=“price” value=“price_$obj_id”}

{assign var=“clean_price” value=“clean_price_$obj_id”}

{assign var=“list_discount” value=“list_discount_$obj_id”}

{assign var=“discount_label” value=“discount_label_$obj_id”}



?

Glad to hear that our answer helped you. Unfortunately the second question is not quite clear. What info do you want to display on the product details page?

Below the price I want to have a message saying '0% finance from £xxx per month (over x months)' which will be filled in depending on the price and not displayed for sale products…

[quote name='amdowney' timestamp='1423741813' post='205139']

Below the price I want to have a message saying '0% finance from £xxx per month (over x months)' which will be filled in depending on the price and not displayed for sale products…

[/quote]



Please try



{if !$product.discount && !$product.list_discount}
{if $product.price > 100}
0% finance from £xxx per month (over 3 months)
{elseif $product.price > 200}
0% finance from £xxx per month (over 7 months)
{/if}
{/if}

Ah OK, will give that a go and let you know.



Just trying to crack the callback settings from the finance provider for order processing updates back in cscart. via http://www.jmtb.co.u…ion&payment=v12



It seems to work with the following updating the cart:



$status =$_REQUEST['flag'];
$orderid =$_REQUEST['SR'];
if ( $status == "D" ) {
fn_change_order_status($orderid, 'D');
fn_finish_payment($orderid, 'D', false);
fn_order_placement_routines('route',$orderid,false);
}




Not sure what they all do but just copied them from other guides etc and it works updating the status and sending the emails, so hope that's that part sorted correctly?

[quote name='eComLabs' timestamp='1423742438' post='205142']

Please try



{if !$product.discount && !$product.list_discount}
{if $product.price > 100}
0% finance from £xxx per month (over 3 months)
{elseif $product.price > 200}
0% finance from £xxx per month (over 7 months)
{/if}
{/if}


[/quote]



That worked a treat, and I added $config.current_location == www.mystore.com to the main if statement as only want this to show on the one store.



I really appreciate your time!

[quote name='tbirnseth' timestamp='1423177723' post='204451']

Not that I know of from the 'cart'. You would have to query the DB for each product to determine if list is greater than price. Note too that any promotion or option-modifier could affect price and would not necessarily give you accurate info.



It is always BEST to keep business logic out of the templates. I.e. use the PHP controllers to add attributes into the cart product at the time they are placed to indicate if price is less than list. Then just look for products with the attribute set or with whatever value you want to look at in it.

[/quote]



Going back to this (the final thing I have to do now on this) how does one access the cart product smarty array exactly?



— edit



OK so using the code {$smarty.session.cart.products|@print_r}

it prints out the following:



Array ( [1519313856] => Array ( [product_id] => 782 [product_code] => 421507 [product] => Nukeproof Mega TR275 Frame - CCDB 2015 [amount] => 1 [product_options] => Array ( [917] => 3197 [1489] =>
5890 ) [price] => 1450 [stored_price] => N [main_pair] => Array ( [pair_id] => 2126 [image_id] => 0 [detailed_id] => 3176 [position] => 0 [detailed] => Array ( [image_path] => http://www.jmtb.co.uk/images
/detailed/3/tr1_y5xy-p8.jpg [alt] => [image_x] => 1270 [image_y] => 927 [http_image_path] => http://www.jmtb.co.uk/images/detailed/3/tr1_y5xy-p8.jpg [absolute_path] => /home/cctvkits/public_html
/images/detailed/3/tr1_y5xy-p8.jpg [relative_path] => detailed/3/tr1_y5xy-p8.jpg ) ) [extra] => Array ( [product_options] => Array ( [917] => 3197 [1489] => 5890 ) [unlimited_download] => N ) [stored_discount]
=> N [company_id] => 2 [amount_total] => 1 [selectable_cart_id] => 4082720985 [options_type] => P [exceptions_type] => F [modifiers_price] => 0 [is_edp] => N [edp_shipping] => N [discount] => 0
[promotions] => Array ( ) [base_price] => 1450 [display_price] => 1450 ) ) 1




So you think the best thing to do will be to add a 'sale' feature to each of the sale products and try and pick that up within the above? Any pointers how I might be able to do that?