Hi Cindy,
I'm running into an issue, non related to OPC but that is affecting it. The way ZC works when it comes to free shipping (free options) and gift vouchers is a bit odd. Ideally if I offer free shipping over $100 and the customer applies a $10 discount coupon for example, free shipping should not apply anymore. However the reality is, with the way ZC is designed free shipping still applies because freeoptions works on order subtotal not order total.
The way I've made it work in the past was by hiding the place order button if certain conditions do not apply. I wrote a rudimentary piece code (perfected by @mc12345678 a little while back, to whom I will forever be grateful to) but I can't make it work with OPC.
The code determines if both discount coupons and free shipping are loaded and if the order total drops below the free shipping threshold, then the button is hidden, for the most part. I placed the code in the tpl_checkout_confirmation_default.php on the native ZC checkout which is where the place order button displays. On OPC that could be according to what I've noticed the module works, on the tpl_modules_opc_submit_block.php, but it just doesn't work, and I was wondering if you could take a look and maybe point me in the right direction?
This below is what I have.
PHP Code:
<?php
// -----
// Part of the One-Page Checkout plugin, provided under GPL 2.0 license by lat9 ().
// Copyright (C) 2013-2017, Vinos de Frutas Tropicales. All rights reserved.
//
// Check to see that at least one shipping-method and one payment-method is enabled; if not, don't render the submit-button.
//
if ($shipping_module_available && $payment_module_available) {
// -----
// Set up two form-submittal buttons, one for payment methods that require confirmation and one for those that don't.
// This page's header_php.php has created an array of payment modules that require confirmation, which is pulled into the
// page's jscript_main.php.
//
?>
<!-- bof disable checkout button from displaying 1 of 3 -->
<?php
if (!IS_ADMIN_FLAG) {
global $order, $db;
if (($order->info['total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) && !empty($_SESSION['cot_gv']) && (($_SESSION['cot_gv'] + $order->info['total']) >= MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN)) { // Do the following (show button) if total is below the min, free options is offered, a gift certificate is used and the sum of the gift certificate and order total is equal to or greater than the minimum.
?>
<!-- bof disable checkout button from displaying 1 of 3 -->
<!--bof submit block -->
<div id="checkoutOneSubmit" class="buttonRow forward">
<span id="opc-order-confirm"><?php echo zen_image_button(BUTTON_IMAGE_CHECKOUT_ONE_CONFIRM, BUTTON_CHECKOUT_ONE_CONFIRM_ALT); ?></span>
<span id="opc-order-review"><?php echo zen_image_button(BUTTON_IMAGE_CHECKOUT_ONE_REVIEW, BUTTON_CHECKOUT_ONE_REVIEW_ALT); ?></span>
<?php echo zen_draw_hidden_field('order_confirmed', '1', 'id="confirm-the-order"') . zen_draw_hidden_field ('current_order_total', '0', 'id="current-order-total"'); ?>
</div>
<?php
if (!empty($order->customer['email_address'])) {
?>
<div id="checkoutOneEmail" class="forward clearRight"><?php echo sprintf(TEXT_CONFIRMATION_EMAILS_SENT_TO, $order->customer['email_address']); ?></div>
<?php
}
?>
<div class="clearBoth"></div>
<!--eof submit block -->
<!-- bof disable checkout button from displaying 2 of 3 -->
<?php } elseif (($order->info['total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) && (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0)) { // Stop checkout if below the minimum and free options is displayed (Note that at this point of execution, the gift certificate is not a factor because if it "helped" then this code is not reached).
echo '<div style="border: 3px solid #777777; padding: 10px 0;"><p style="text-align: center;"><strong>Your order no longer qualifies for Free Shipping.</strong></p>';
} else { // standard checkout, basically total is anything that doesn't cause freeoptions to display.
?>
<!-- eof disable checkout button from displaying 2 of 2 -->
<!--bof submit block -->
<div id="checkoutOneSubmit" class="buttonRow forward">
<span id="opc-order-confirm"><?php echo zen_image_button(BUTTON_IMAGE_CHECKOUT_ONE_CONFIRM, BUTTON_CHECKOUT_ONE_CONFIRM_ALT); ?></span>
<span id="opc-order-review"><?php echo zen_image_button(BUTTON_IMAGE_CHECKOUT_ONE_REVIEW, BUTTON_CHECKOUT_ONE_REVIEW_ALT); ?></span>
<?php echo zen_draw_hidden_field('order_confirmed', '1', 'id="confirm-the-order"') . zen_draw_hidden_field ('current_order_total', '0', 'id="current-order-total"'); ?>
</div>
<?php
if (!empty($order->customer['email_address'])) {
?>
<div id="checkoutOneEmail" class="forward clearRight"><?php echo sprintf(TEXT_CONFIRMATION_EMAILS_SENT_TO, $order->customer['email_address']); ?></div>
<?php
}
?>
<div class="clearBoth"></div>
<!--eof submit block -->
//<!-- bof disable checkout button from displaying 3 of 3 -->
<?php
}
}
When loading the page I get a popup "Please contact the store owner; some required elements of this page are missing" and in the logs "PHP Parse error: syntax error, unexpected end of file in /includes/templates/responsive_classic/templates/tpl_modules_opc_submit_block.php on line 68."
Thanks in advance for your guidance.