Fixing the woocommerce shop links to not use IDs
authorLaury GvR <laury@gaslightmedia.com>
Tue, 1 Nov 2016 17:43:08 +0000 (13:43 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Tue, 1 Nov 2016 17:43:08 +0000 (13:43 -0400)
The links in the shop header were using IDs instead of the
Woocommerce functions to get the urls for such pages as the cart,
checkout, logout, etc.

woocommerce.php

index 1c727dc..bf6ab41 100644 (file)
                             <div id="woo-quick-display" class="small-12 medium-9 columns">
                                 <div id="woo-quick-cart-icon" class="small-3 columns left">
                                     <div class="woo-quick-cart-image">
-                                        <a href="<?php echo get_permalink(99);?>">
+                                        <a href="<?php echo $woocommerce->cart->get_cart_url();?>">
                                             <img src="<?php echo get_template_directory_uri(); ?>/assets/shopping-cart.png">
                                         </a>
-                                        <a href="<?php echo get_permalink(99);?>"><h3>view cart</h3></a>
+                                        <a href="<?php echo $woocommerce->cart->get_cart_url();?>"><h3>view cart</h3></a>
                                     </div>
 
                                 </div>
                                 </div>
                                 <div id="woo-quick-checkout" class="small-4 columns right">
                                     <?php
-                                        if (is_user_logged_in()) {
-                                            echo '<a href="'. get_permalink(101) . '?customer-logout=true" class="button login_toggle">log out</a>';
+                                        $myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' );
+                                        if (is_user_logged_in()) { 
+                                            echo '<a href="'. get_permalink( $myaccount_page_id ) . '?customer-logout=true" class="button login_toggle">log out</a>';
                                         }
                                         elseif (!is_user_logged_in()) {
-                                            echo '<a href="'. get_permalink(101) . '" class="button login_toggle">log in</a>';
+                                            echo '<a href="'. get_permalink( $myaccount_page_id ) . '" class="button login_toggle">log in</a>';
                                         }
                                     ?>
-                                    <a href="<?php echo get_permalink(100); ?>" class="button">checkout</a>
+                                    <a href="<?php echo $woocommerce->cart->get_checkout_url(); ?>" class="button">checkout</a>
                                 </div>
                             </div>
                         <?php if (is_shop()) { ?>