Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$coupon_code is not available in cart-footer.php #275

Closed
acasperw opened this issue May 28, 2021 · 3 comments
Closed

$coupon_code is not available in cart-footer.php #275

acasperw opened this issue May 28, 2021 · 3 comments

Comments

@acasperw
Copy link

I wanted to move the coupon section from sitting above in the cart.php wrapper, to the cart footer in a side by side layout with the cart summary, however, when i try to <? echo $coupon_code; ?> here, nothing is outputted

* @var string $coupon_code Coupons calculation and sumary.

@acasperw
Copy link
Author

Is there some other way this is available within this template that i am missing?

@yuenvision
Copy link

Will investigate for v4.14.0

@yuenvision
Copy link

Hi, @acasperw,
The $coupon_code var is no longer available in the cart-footer.php template. We'll remove it from the template description and update the template version number.

If you want to add the coupon_code var to the cart-footer template, here is how to do it:

add_filter( 'bigcommerce/template=components/cart/cart-footer.php/data', function ( $data, $template, $options ) {
    if ( get_option( \BigCommerce\Customizer\Sections\Cart::ENABLE_COUPON_CODE, false ) === 'yes' ) {
        $component = \BigCommerce\Templates\Cart_Coupon_Code::factory( [
            \BigCommerce\Templates\Cart_Coupon_Code::COUPONS => $data['cart']['coupons'],
        ] );
        
        $data[ \BigCommerce\Templates\Cart::COUPON_CODE ] = $component->render();
    }

    return $data;
}, 10, 3 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants