Replace Button in woocommerce by a clickable Image in PhP - php

I sell online Gift Cards using Woocommerce on Wordpress. On the thank you page it displays the download image (containing the Gift Card Key) as a button.
I would like it to display the image itself to be downloaded in full size above the the download link.
Screenshot of the Thank You Page
Here's the part that displays the download section in PHP:
<?php break;
case 'download-file' : ?>
<a href="<?php echo esc_url( $download['download_url'] ); ?>" class="woocommerce-MyAccount-downloads-file">
<?php echo esc_html( $download['file']['name'] ); ?>
</a>
Can you help me out plz?

Try this code. you have to download attribute to <a> tag
<?php
break;
case 'download-file' : ?>
<a href="<?php echo esc_url( $download['download_url'] ); ?>"
class="woocommerce-MyAccount-downloads-file" download>
<?php echo esc_html( $download['file']['name'] ); ?>
</a>

Related

Show cart and chekout in the header woocomerece

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>

How to define current product thumbnail in woocommerce?

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>

Woocommerce 'recent products' assistance

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

Url link to feature image in the portfolio wordpress

I am new to Wordpress. i have issue with Feature image. just i need to add URL to feature image(when we click on that feature image , it should redirect to that particular URL).
also is it possible to give URL to Title of the Portfolio categories page which i used in normal page.
You need to add this code in your php file :
<?php if ( has_post_thumbnail()) {
echo '<a href="' . get_permalink($post->ID) . '" >';
the_post_thumbnail();
echo '</a>';
}?>
<?php the_title(); ?>
<?php the_post_thumbnail( 'large' ); ?>
instead of this <?php the_permalink(); ?> you can assign your own url
use <?php the_permalink(); ?> for add Url link to feature image in portfolio in wordpress.
This worked finally.
<a href="<?php echo get_post_meta($post->ID, $sr_prefix.'_portfolio_externalurl', true); ?>"><?php } the_post_thumbnail('portfolio-crop-thumb');

If comment_author_link then put the link around avatar image

In the functions.php file for my theme the .commentslist shows a gravatar and if the user fills in a url in the comment form, you get a
comment_author_link()
Which prints a link with the name.
I want to put a link around the .avatar image IF there is a link. There is zip/zilch in the resources (https://developer.wordpress.org/?s=comment_author&post_type[]=wp-parser-function&post_type[]=wp-parser-hook&post_type[]=wp-parser-class&post_type[]=wp-parser-method).
It would be like this but this doesn't work:
<?php if ( has_comment_author_link() ) : ?>
<a href="<?php echo comment_author_url();?>" target="_blank">
<?php endif; ?>
<?php echo get_avatar( $comment, $size='75' ); ?>
<?php if ( has_comment_author_link() ) : ?>
</a>
<?php endif; ?>
But there is no such "has_comment_author_link" and I don't know how to create this.
Thanks!
Solved at Wordpress stackexchange: https://wordpress.stackexchange.com/questions/172152/if-there-is-a-comment-author-link-put-url-around-the-avatar-image/172156#172156

Categories