Jump to content

pro rata


Sybille

Recommended Posts

Hi,

 

Is it possible, to check on the config product if a product has pro rata billing activated or not.

If pro rata billing for the particular product is activated I’d like to show a text, which says the price for the product is calculated by pro rata.

 

On the cart page the variable $products.prorata is available but not on the config product page.

 

Many thanks for your support.

Sybille

Link to comment
Share on other sites

Hi Sybille,

 

Is it possible, to check on the config product if a product has pro rata billing activated or not.

If pro rata billing for the particular product is activated I’d like to show a text, which says the price for the product is calculated by pro rata.

On the cart page the variable $products.prorata is available but not on the config product page.

ahh, from memory I think you're correct and it's not available to that page.

 

if so, the usual next step would be to write a hook to get the value... you'll be able to get the product ID (pid) from the template and use that in either a very basic db query, or via the class docs - get the prorata value, send it back to the template and then modify the template to show your message at the location of your choice if the variable equals 1 (or whatever you set the value to be).

Link to comment
Share on other sites

  • 3 weeks later...
Many thanks for your answer and explanation. Sounds quiet complicated. I guess I'm not able to do the hook on my own. May you please help me with it?!

the hook would basically be...

 

<?php

/**
* Detect if current cart product uses Pro Rata Option
* @author brian!
*/

use Illuminate\Database\Capsule\Manager as Capsule;

function cart_prorata_hook($vars)
{
   if ($vars['templatefile']=='configureproduct'){

       $pid = $vars['productinfo']['pid'];
       $prorata = Capsule::table('tblproducts')
               ->where('id',$pid)
               ->value('proratabilling');

       if ($prorata == "1") {
           return array("prorata" => $prorata);
       }
   }
}
add_hook("ClientAreaPageCart", 1, "cart_prorata_hook");

and then somewhere appropriate in the configureproduct.tpl template, you would use...

{if $prorata}this is a prorata product{/if}

or whatever text you wish to output if the product uses prorata.

Link to comment
Share on other sites

Is it possible to get the output on the ordersummary?

not as easily... depending on which order summary you mean...

 

if it's the one at the configure product stage, then the variables would be different and the prorata value would still be missing by default, so you'd need another hook to get it;

if it's the one at the viewcart stage, then you could potentially have multiple products in the cart, each of which may or may not be using pro rata... so again you would need a hook, but it might need to be a lot more complicated to cover all eventualities.

Link to comment
Share on other sites

First I need it on the order summary...

when you say first, that implies there's going to be a second, third & fourth! :)

 

the one on the product config stage (ordersummary.tpl). I thought I could use the same hook and just change "ClientAreaPageCart" in the string "add_hook("ClientAreaPageCart", 1, "cart_prorata_hook");"

well that wouldn't work for a number of reasons... not the least of which is that I don't think ordersummary can use hooks... it's not a template in the true sense, it's just a js included template, so I don't think it triggers any hook points.

 

you could probably do it using {php} tags in the ordersummary template - but that's frowned upon and not a habit to get into using.... while you could get the PID value from the template, you'd still have to query the database to get the prorata value... if your using v6, then you can't use the classes as an alternative.

 

unless you're prepared to put the work in, it would be easier to just output the prorata text in the proper templates, e.g configureproduct

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated