I made a custom template for my-orders.php and to show specification of an order when I add the links, I get
view-order/?order="order number" as permalink. should me view-order/"ordernumber"
Code added:
?><tr class="order">
<td class="order-number">
<a href="<?php echo $order->get_view_order_url(); ?>">
<?php echo $order->get_order_number(); ?>
</a>
</td>
yeah I found this problem as well.
I spent some time trying to manipulate the woo commerce 2.1 before I realized it wasn't even being used.
Instead my theme actually had it's own account pages which didn't work with the 2.1 that was causing the problem. So I found a file in my theme called my-orders.php and had to yank out the part I didn't want:
The guilty code was caused by
<a href="<?php echo esc_url( add_query_arg('order', $order->id, get_permalink( woocommerce_get_page_id( 'view_order' ) ) ) ); ?>">
and I just pulled out the offending non compatible with 2.1 bits:
<a href="<?php echo str_replace('?order=','',esc_url( add_query_arg('order', $order->id, get_permalink( woocommerce_get_page_id( 'view_order' ) ) ) ) ); ?>">
I actually had to make this change in 2 place in this file
I'm just pulling about the old style url:
str_replace('?order=','', OFFENDING STRING )
You should check your permalink structure in the WordPress settings. $order->get_view_order_url(); will give you pretty perma structure if your settings are correct.
Related
Hi all maybe someone is aware on how to add cart page and checkout page content into the header.php so it shows on every page? tried looking but haven't found a proper answer. any help is appreciated.
No need to write a single piece of code ;)
A free plugin is already available in Wordpress and it will let you add minicart as a widget to any of your sidebar (here in top bar).
Hi, the below code may help you
<?php
global $woocommerce;
$qty = $woocommerce->cart->get_cart_contents_count();
$total = $woocommerce->cart->get_cart_total();
$cart_url = $woocommerce->cart->get_cart_url();
echo $loginout = wp_loginout($_SERVER['REQUEST_URI'], false ); // show wp dynamic login / logout link
?>
<a href="<?php echo $woocommerce->cart->get_checkout_url() ?>" title="<?php _e( 'Checkout' ) ?>">
<?php _e( 'Checkout' ) ?>
</a> |
<a href="<?php echo $cart_url ?>" title="<?php _e( 'Cart' ) ?>">
<?php _e( 'Cart ( '. $qty .' ) -'. $total ) ?>
</a>
I am currently working on a shop page which works with Wordpress + Woocommerce Plugin. I edited the woocommerce Files so that I have custom products, menus and so on.
I managed to get current images from my products, but now I want them to appear on click (the little image Icon, on the Screenshot)
But instead of showing the current product image it shows the first image of each category
.
Here is my current code that loads the wrong product thumbnail:
<div class="modal-content">
<a itemprop="image" href="<?php echo wp_get_attachment_url( get_post_thumbnail_id() ); ?>" class="zoom" rel="thumbnails" title="<?php echo get_the_title( get_post_thumbnail_id() ); ?>">
<?php echo get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) ) ?>
</a></div>
It is located in woocommerce/content-product.php.
Thank you in advance
Nico
So this is the solution, I had to create dynamic IDs. As I wrote it was always the same image, the reason of this was that there was only one ID and not multiple/dynamic.
This was the code I had to add to the id:
<div id="modal-<?php echo $product->id ?>" class="modal">
And here is the other one:
<a data-target="modal-<?php echo $product->id; ?>" class="modal-trigger"><i class="material-icons red-text right">photo</i></a>
Using WordPress on the default twentysixteen theme. This is a code issue not a theme issue which is why I'm posting it on SO. I have a feeling I'm just doing something simple wrong but I've searched and figured out what code I need to change but it seems like it's not making the changes as expected.
So what I'd like to do is change the LOGO that is currently going to the website "home". I'm talking about the front end logo at the top left that i'd like to go to one of my other sites which has more relevant information.
But when I change this code:
<div class="header-image">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
<img src="<?php header_image(); ?>" srcset="<?php echo esc_attr( wp_get_attachment_image_srcset( get_custom_header()->attachment_id ) ); ?>" sizes="<?php echo esc_attr( $custom_header_sizes ); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
</a>
To:
<div class="header-image">
<a href="http://external-website-here.com">
<img src="<?php header_image(); ?>" srcset="<?php echo esc_attr( wp_get_attachment_image_srcset( get_custom_header()->attachment_id ) ); ?>" sizes="<?php echo esc_attr( $custom_header_sizes ); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
</a>
It doesn't seem to be affecting where I'm redirected when clicking on the logo image. In other words it still goes to the home_url it seems instead of the external site.
Any suggestions are much appreciated.
Additional Information: No caching is enabled, tried other browser/devices to make sure it's not a cache issue.
Update: Even remove the entire code from my first code box it doesn't change anything on the front end. Maybe I'm modifying the wrong file? How do I figure out what file the logo code is living in?
You're looking at the wrong code.
You need to edit line 35 and 37 of the header.php, which I can see here: https://github.com/WordPress/twentysixteen/blob/master/header.php
This is because you don't have a logo, as far as I can tell anyway.
Update:
I've updated your site to work.
What I did was add function to filter the home url;
//functions.php (end of file)
/**
* Changes the url returned from home_url();
*/
function change_home_link($url, $path, $orig_scheme, $blog_id){
return 'http://google.com';
}
Then add and remove the filter in the header
//header.php line 32
add_filter( 'home_url', 'change_home_link' );
twentysixteen_the_custom_logo();
remove_filter( 'home_url', 'change_home_link' );
You could also just remove the twentysixteen_the_custom_logo() function and replace it with what ever you want.
I am using WordPress 4.3.1, Woocommerce 2.4.7 and the theme storefront 1.5.1.
I want to change the "site-header-cart" in the header, that displays the current price of the cart along the amount of items in the cart, to only show the number of items:
<span class="amount">463,33 €</span>
<span class="count">7 items</span>
Should be:
<span class="count">7</span>
Whenever I make changes to template-tags.php only changes outside of the
<a class="cart-contents" ...>
...
</a>
are being displayed. Whenever I try to change something inside the href the unchanged original will show up:
if ( ! function_exists( 'storefront_cart_link' ) ) {
function storefront_cart_link() {
?>
<a class="cart-contents" href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" title="<?php _e( 'View your shopping cart', 'storefront' ); ?>">
<span class="count"><?php echo wp_kses_data( sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'storefront' ), WC()->cart->get_cart_contents_count() ) );?></span>
</a>
<?php
}
}
Whats going on, can anyone help me ?
I had the same Issue. The fact is, that you have to make a operation on the cart like add a item or empty the cart to get your changes visible. Another option is clearing the sessionStorage like Loque described.
1. Add code to your custom functions.php
if ( ! function_exists( 'storefront_cart_link' ) ) {
function storefront_cart_link() {
?>
<a class="cart-contents" href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" title="<?php _e( 'View your shopping cart', 'storefront' ); ?>">
<span class="count"><?php echo WC()->cart->get_cart_contents_count();?></span>
</a>
<?php
}
}
2. Do a operation on the cart or clear the sessionStorage in Console:
sessionStorage.removeItem('wc_fragments')
3. Refresh your Browser --> very Important
Before:
<span class="count">1 items</span>
After:
<span class="count">1</span>
I am using the shortcode [recent_products per_page="3" columns="3"] in one of my pages.
I am unable to edit this page in the mytheme/woocommerce/content-widget-product.php page but any changes I am making are not getting applied. Am I editing the correct file? Is there a way to edit how this shortcode displays that I do not know about?
Any assistance to resolve this issue is appreciated.
<?php global $product; ?>
<li>
<a href="<?php echo esc_url( get_permalink( $product->id ) ); ?>" title="<?php echo esc_attr( $product->get_title() ); ?>">
<?php echo $product->get_image(); ?>
<span class="product-title"><?php echo $product->get_title(); ?></span>
</a>
<?php if ( ! empty( $show_rating ) ) echo $product->get_rating_html(); ?>
<?php echo $product->get_price_html(); ?>
</li>
This is the code that I am trying to edit - to no avail.
Check if you update the files on server.
If you bought the template, probably you haven't access to the code of that widget.
Anyway, I think you are editing the wrong file.
Show some code please