Jump to content
cinolas

Displaying totals on checkout_payment.php page

Recommended Posts

Hi,

I'm using osC 2.3.4 Gold BS and I'm looking for a way to display the order subtotal and total on the checkout_payment.php page.

I had it working. I just copy-pastaed this line (echo $oscTemplate->getContent('payment');) from checkout_confirmation.php into my checkout_payment.php:

    <div class="col-sm-8">
      <div class="panel panel-warning">
        <div class="panel-body">
        <?php echo TEXT_SELECT_PAYMENT_METHOD; ?><hr />
        <?php echo $oscTemplate->getContent('payment'); ?>
        </div>
      </div>
    </div>

This worked great. However now that I'm installing the Gift Voucher contribution, which also modifies the checkout_payment.php page, it's giving me this error:

PHP Fatal error:  Cannot redeclare class order_total in /includes/classes/order_total.php on line 13

Line 13 of my order_total.php is as expected :

class order_total {

So, I understand that the problem is that the order_total class is being declared twice. But I don't understand why $oscTemplate->getContent('payment'); would cause the order_total class to be declared. Admittedly, I have no idea how the template system works (but would love to learn!), or why that line brought up the totals when it worked. I'm a copy-pasta hack with very little actual knowledge of php.

Is there a better way to summon the totals without redeclaring the class?

I tried changing line 75, which is a line that is added by the Gift Voucher contributio, from require(DIR_WS_CLASSES . 'order_total.php'); to require_once(DIR_WS_CLASSES . 'order_total.php'); thinking it might prevent the class from being re-declared but it didn't seem to make a difference.

Any hints? Cheers!

Edited by cinolas

Share this post


Link to post
Share on other sites
29 minutes ago, cinolas said:

I tried changing line 75, which is a line that is added by the Gift Voucher contributio, from require(DIR_WS_CLASSES . 'order_total.php'); to require_once(DIR_WS_CLASSES . 'order_total.php');

Try

if (!class_exists('order_total')) {
  require 'includes/classes/order_total.php';
}

Or just delete the line entirely. 

If that doesn't work, you probably need to change the other place that has that line in one of the three ways (require_once, check if class exists, remove). 


Always back up before making changes.

Share this post


Link to post
Share on other sites

I had tried removing it all together and it just causes an error 500.

I tried adding the IF just now, and it didn't change anything.

The $oscTemplate->getContent('payment'); I added is located after the require. So I'm assuming it's the $oscTemplate->getContent('payment'); that causes the redeclaration.

Any idea where/how $oscTemplate->getContent('payment'); causes the the order_total class to be required again?

What files are involved when the line $oscTemplate->getContent('payment'); is used? So I can go try fixes there.

Cheers!

Share this post


Link to post
Share on other sites
5 hours ago, cinolas said:

What files are involved when the line $oscTemplate->getContent('payment'); is used?

That loads in all of the modules the payment has. My guess is that you will need to change the includes/modules/content/checkout_payment/cm_cp_payment_methods_gift_vouchers.php file. But first check the checkout_payment.php file to be sure you do not have two of the $oscTemplate->getContent('payment');  statements. If you are using the Gold version, then it may not be there. But if you are using the Frozen version, or one in-between, it will be in the file already, as I recall.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×