I want reverse description and short description single product pages on woocommerce . I try this tuto : http://www.kriesi.at/support/topic/reverse-description-and-short-description-single-product-pages/ .
Short description work but not description .
I use woocommercer version 2.3.7 .
Thank
You could just swap the excerpt and the main content in the backend.... save the content in the excerpt box and vice versa. Otherwise, you need to override 2 WooCommerce templates and reverse the content with the excerpt.
In your theme, add this as woocommerce/single-product/short-description.php. post_excerpt is replaced with post_content.
<?php
/**
* Single product short description
*
* #author WooThemes
* #package WooCommerce/Templates
* #version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
global $post;
if ( ! $post->post_content ) {
return;
}
?>
<div itemprop="description">
<?php the_content() ?>
</div>
and this as woocommerce/single-product/tabs/description.php:
<?php
/**
* Description tab
*
* #author WooThemes
* #package WooCommerce/Templates
* #version 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
global $post;
$heading = esc_html( apply_filters( 'woocommerce_product_description_heading', __( 'Product Description', 'woocommerce' ) ) );
?>
<?php if ( $heading ): ?>
<h2><?php echo $heading; ?></h2>
<?php endif; ?>
<?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>
Basically, <?php the_content(); ?> echoes the full description, while <?php the_excerpt(); ?> echoes the short description.
In your layout, just switch them to echo whatever you want. Be sure too that both textareas (content/excerpt) in your product post contain some text.
Related
The current template has the following,
<?php
/**
* Customer new account email
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-new-account.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #package WooCommerce\Templates\Emails
* #version 6.0.0
*/
defined( 'ABSPATH' ) || exit;
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<?php /* translators: %s: Customer username */ ?>
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $user_login ) ); ?></p>
<?php /* translators: %1$s: Site title, %2$s: Username, %3$s: My account link */ ?>
<p><?php printf( esc_html__( 'Thanks for creating an account on %1$s. Your username is %2$s. You can access your account area to view orders, change your password, and more at: %3$s', 'woocommerce' ), esc_html( $blogname ), '<strong>' . esc_html( $user_login ) . '</strong>', make_clickable( esc_url( wc_get_page_permalink( 'myaccount' ) ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<?php if ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) && $password_generated && $set_password_url ) : ?>
<?php // If the password has not been set by the user during the sign up process, send them a link to set a new password ?>
<p><?php printf( esc_html__( 'Click here to set your new password.', 'woocommerce' ) ); ?></p>
<?php endif; ?>
<?php
/**
* Show user-defined additional content - this is set in each email's settings.
*/
if ( $additional_content ) {
echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
}
do_action( 'woocommerce_email_footer', $email );
But I am in need of changing the link to another page. How do I do that.
I tried to simply change the myaccount to login where the my page is,
make_clickable( esc_url( wc_get_page_permalink( 'login' ) ) ) );
But it seems like not working.
Also, I'm required to remove the Click here to set your new password.
Please share your wisdom how I can do that. I am new to this thing. Thanks.
I am using the Divi theme with WooCommerce and WooCommerce Local Pickup Plus. I did all the settings correctly according to the documentation.
When the order is placed a Thank You page appears where I display the order details. This is Local Pickup Plus order detail code
<?php
/**
* WooCommerce Local Pickup Plus
* #author SkyVerge
* #copyright Copyright (c) 2012-2022, SkyVerge, Inc.
* #license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
*/
defined( 'ABSPATH' ) or exit;
/**
* WooCommerce Local Pickup Plus order pickup details template file.
*
* #type \WC_Order $order Order being displayed
* #type array $pickup_data Pickup data for given order
* #type \WC_Shipping_Local_Pickup_Plus $shipping_method Local Pickup Plus Shipping Method instance
*
* #version 2.0.0
* #since 2.0.0
*/
?>
<tr class="wc-local-pickup-plus">
<th><?php echo esc_html( $shipping_method->get_method_title() ); ?>:</th>
<td>
<?php $package_number = 1; ?>
<?php $packages_count = count( $pickup_data ); ?>
<?php foreach ( $pickup_data as $pickup_meta ) : ?>
<div>
<?php if ( $packages_count > 1 ) : ?>
<h5><?php echo sprintf( is_rtl() ? '#%2$s %1$s': '%1$s #%2$s', esc_html( $shipping_method->get_method_title() ), $package_number ); ?></h5>
<?php endif; ?>
<?php foreach ( $pickup_meta as $label => $value ) : ?>
<?php if ( is_rtl() ) : ?>
<small><?php echo wp_kses_post( $value ); ?> <strong>:<?php echo esc_html( $label ); ?></strong></small><br />
<?php else : ?>
<small><strong><?php echo esc_html( $label ); ?>:</strong> <?php echo wp_kses_post( $value ); ?></small><br />
<?php endif; ?>
<?php endforeach; ?>
<?php if ( $packages_count > 1 && $package_number <=$packages_count ) : ?>
<br />
<?php endif; ?>
<?php $package_number++; ?>
</div>
<?php endforeach; ?>
</td>
</tr>
Now the problem is that the $pickup_meta is sending the empty value. It did not display the pickup location or address on the order page when it is successful.
The link for the order page is given
https://www.vinnavinna.se/kassa/order-received/2648/?key=wc_order_UId9nKkXOgRVZ
The other issue that I am facing is if I select the local pickup still, I get the error message to enter the address for billing.
Unfortunately, WooCommerceLocal Pickup Plus is not compatible with Divi Page Builder.
When I tried to use Divi builder and add code and place [woocommerce_checkout] it did not work. It works when I chose the default editor and place the shortcut i.e. [woocommerce_checkout]
I am here and trying to get the payment form below the shipping form. like that explained in the image.
Example Image just Form not CSS
I have found these codes on the internet with this image need help to understand this.
this code will be placed in function.php
<?php
/**
* Moving the payments
*/
add_action( 'woocommerce_checkout_shipping', 'my_custom_display_payments', 20 );
/**
* Displaying the Payment Gateways
*/
function my_custom_display_payments() {
if ( WC()->cart->needs_payment() ) {
$available_gateways = WC()->payment_gateways()->get_available_payment_gateways();
WC()->payment_gateways()->set_current_gateway( $available_gateways );
} else {
$available_gateways = array();
}
?>
<div id="checkout_payments">
<h3><?php esc_html_e( 'Billing', 'woocommerce' ); ?></h3>
<?php if ( WC()->cart->needs_payment() ) : ?>
<ul class="wc_payment_methods payment_methods methods">
<?php
if ( ! empty( $available_gateways ) ) {
foreach ( $available_gateways as $gateway ) {
wc_get_template( 'checkout/payment-method.php', array( 'gateway' => $gateway ) );
}
} else {
echo '<li class="woocommerce-notice woocommerce-notice--info woocommerce-info">' . apply_filters( 'woocommerce_no_available_payment_methods_message', WC()->customer->get_billing_country() ? esc_html__( 'Sorry, it seems that there are no available payment methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ) : esc_html__( 'Please fill in your details above to see available payment methods.', 'woocommerce' ) ) . '</li>'; // #codingStandardsIgnoreLine
}
?>
</ul>
<?php endif; ?>
</div>
<?php
}
This Code Also Placed in function.php for order review fragmentation.
<?php
/**
* Adding the payment fragment to the WC order review AJAX response
*/
add_filter( 'woocommerce_update_order_review_fragments', 'my_custom_payment_fragment' );
/**
* Adding our payment gateways to the fragment #checkout_payments so that this HTML is replaced with the updated one.
*/
function my_custom_payment_fragment( $fragments ) {
ob_start();
my_custom_display_payments();
$html = ob_get_clean();
$fragments['#checkout_payments'] = $html;
return $fragments;
}
This Code will be placed in the child theme template payment.php
<?php
/**
* Checkout Payment Section
*
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/payment.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files, and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #package WooCommerce/Templates
* #version 3.5.3
*/
defined( 'ABSPATH' ) || exit;
if ( ! is_ajax() ) {
do_action( 'woocommerce_review_order_before_payment' );
}
?>
<div id="payment" class="woocommerce-checkout-payment">
<div class="form-row place-order">
<noscript>
<?php
/* translators: $1 and $2 opening and closing emphasis tags respectively */
printf( esc_html__( 'Since your browser does not support JavaScript, or it is disabled, please ensure you click the %1$sUpdate Totals%2$s button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'woocommerce' ), '<em>', '</em>' );
?>
<br/><button type="submit" class="button alt" name="woocommerce_checkout_update_totals" value="<?php esc_attr_e( 'Update totals', 'woocommerce' ); ?>"><?php esc_html_e( 'Update totals', 'woocommerce' ); ?></button>
</noscript>
<?php wc_get_template( 'checkout/terms.php' ); ?>
<?php do_action( 'woocommerce_review_order_before_submit' ); ?>
<?php echo apply_filters( 'woocommerce_order_button_html', '<button type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '">' . esc_html( $order_button_text ) . '</button>' ); // #codingStandardsIgnoreLine ?>
<?php do_action( 'woocommerce_review_order_after_submit' ); ?>
<?php wp_nonce_field( 'woocommerce-process_checkout', 'woocommerce-process-checkout-nonce' ); ?>
</div>
</div>
<?php
if ( ! is_ajax() ) {
do_action( 'woocommerce_review_order_after_payment' );
}
if I add first code in function.php the website stop working and shows There has been a critical error on this website.
I have some products and I have setup some cross sell and up-selling products. But there is a case when cross-selling products are out of stock.
What I need to place into functions.php in order to display only available crosselling and upselling products?
I checked if there are any hooks available to modify the products to show but I didn't find it. I believe the only solution is to modify the respective templates.
Find them here:
/woocommerce/single-product/up-sells.php
/woocommerce/cart/cross-sells.php
A control will be added in the loop of each Upsells and Cross-sells template to hide each product that:
it is out of stock
and does not allow backorders
The new templates will be copied into your active child
theme.
CROSS-SELLS
You will need to add the following line as the first expression within the foreach:
<?php if ( ! $cross_sell->is_in_stock() && ! $cross_sell->backorders_allowed() ) : continue; endif; ?>
The complete page will be:
<?php
/**
* Cross-sells
*
* This template can be overridden by copying it to yourtheme/woocommerce/cart/cross-sells.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #package WooCommerce\Templates
* #version 4.4.0
*/
defined( 'ABSPATH' ) || exit;
if ( $cross_sells ) : ?>
<div class="cross-sells">
<?php
$heading = apply_filters( 'woocommerce_product_cross_sells_products_heading', __( 'You may be interested in…', 'woocommerce' ) );
if ( $heading ) :
?>
<h2><?php echo esc_html( $heading ); ?></h2>
<?php endif; ?>
<?php woocommerce_product_loop_start(); ?>
<?php foreach ( $cross_sells as $cross_sell ) : ?>
<?php if ( ! $cross_sell->is_in_stock() && ! $cross_sell->backorders_allowed() ) : continue; endif; ?>
<?php
$post_object = get_post( $cross_sell->get_id() );
setup_postdata( $GLOBALS['post'] =& $post_object ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited, Squiz.PHP.DisallowMultipleAssignments.Found
wc_get_template_part( 'content', 'product' );
?>
<?php endforeach; ?>
<?php woocommerce_product_loop_end(); ?>
</div>
<?php
endif;
wp_reset_postdata();
UPSELLS
You will need to add the following line as the first expression within the foreach:
<?php if ( ! $upsell->is_in_stock() && ! $upsell->backorders_allowed() ) : continue; endif; ?>
The complete page will be:
<?php
/**
* Single Product Up-Sells
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/up-sells.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #package WooCommerce\Templates
* #version 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( $upsells ) : ?>
<section class="up-sells upsells products">
<?php
$heading = apply_filters( 'woocommerce_product_upsells_products_heading', __( 'You may also like…', 'woocommerce' ) );
if ( $heading ) :
?>
<h2><?php echo esc_html( $heading ); ?></h2>
<?php endif; ?>
<?php woocommerce_product_loop_start(); ?>
<?php foreach ( $upsells as $upsell ) : ?>
<?php if ( ! $upsell->is_in_stock() && ! $upsell->backorders_allowed() ) : continue; endif; ?>
<?php
$post_object = get_post( $upsell->get_id() );
setup_postdata( $GLOBALS['post'] =& $post_object ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited, Squiz.PHP.DisallowMultipleAssignments.Found
wc_get_template_part( 'content', 'product' );
?>
<?php endforeach; ?>
<?php woocommerce_product_loop_end(); ?>
</section>
<?php
endif;
wp_reset_postdata();
The code has been tested and works.
I'm using Wordpress with WooCommerce, I've made a custom theme (so possibly part of the problem) but I've based it off the default Wordpress theme.
When I click on a product page that doesn't have ANY pictures, the layout is fine and it shows a blank picture image.
When I then add an image to the same product, refresh the page product page, the layout style for the tabs disappears and instead the tabs are displayed as text with no style. It appears that the ::before and ::after code is present on the "no image" tabs, but when I add an image they disappear!
The style for the image also changes, the size goes crazy and there is no padding on the right of the image so the description/title/add to cart touches the image!
Site: http://frenchies-boutique.wadessolutions.com
The site was build around the Twenty Fifteen theme.
single-product.php
<?php
/**
* The Template for displaying all single products.
*
* Override this template by copying it to yourtheme/woocommerce/single-product.php
*
* #author WooThemes
* #package WooCommerce/Templates
* #version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
get_header( 'shop' ); ?>
<?php
/**
* woocommerce_before_main_content hook
*
* #hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* #hooked woocommerce_breadcrumb - 20
*/
do_action( 'woocommerce_before_main_content' );
?>
<?php while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( 'content', 'single-product' ); ?>
<?php endwhile; // end of the loop. ?>
<?php
/**
* woocommerce_after_main_content hook
*
* #hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
?>
<?php
/**
* woocommerce_sidebar hook
*
* #hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommerce_sidebar' );
?>
<?php get_footer( 'shop' ); ?>
product-image.php
<?php
/**
* Single Product Image
*
* #author WooThemes
* #package WooCommerce/Templates
* #version 2.0.14
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
global $post, $woocommerce, $product;
?>
<div class="images">
<?php
if ( has_post_thumbnail() ) {
$image_title = esc_attr( get_the_title( get_post_thumbnail_id() ) );
$image_caption = get_post( get_post_thumbnail_id() )->post_excerpt;
$image_link = wp_get_attachment_url( get_post_thumbnail_id() );
$image = get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ), array(
'title' => $image_title,
'alt' => $image_title
) );
$attachment_count = count( $product->get_gallery_attachment_ids() );
if ( $attachment_count > 0 ) {
$gallery = '[product-gallery]';
} else {
$gallery = '';
}
echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '%s', $image_link, $image_caption, $image ), $post->ID );
} else {
echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<img src="%s" alt="%s" />', wc_placeholder_img_src(), __( 'Placeholder', 'woocommerce' ) ), $post->ID );
}
?>
<?php do_action( 'woocommerce_product_thumbnails' ); ?>
</div>
thanks