Syed Tarikul Islam
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] How do I display product unit price in woocommerce order mailHi, @jai6358
To display the product unit price in WooCommerce order emails, you can achieve this by customizing the email template. WooCommerce uses hooks and templates to generate emails, so you can modify the templates to display additional information like unit price.
Here’s how you can do it:Step 1: Create a Child Theme (if you haven’t already)
Always create a child theme for modifications, so your changes are preserved during WooCommerce and theme updates.
- If you haven’t created a child theme, follow the steps here.
Step 2: Copy the Email Template
You need to modify the
email-order-items.php
template. Here’s how to find and copy the correct template:- Navigate to the WooCommerce plugin directory:
/wp-content/plugins/woocommerce/templates/emails/
- Copy the file
email-order-items.php
to your child theme at this location:/wp-content/themes/your-child-theme/woocommerce/emails/
Step 3: Modify the
email-order-items.php
TemplateNow, you can modify the copied template to add a new column for the unit price.
- Open the copied
email-order-items.php
file in your child theme. - Find the section that outputs the product information, usually within a table structure, where the subtotal is displayed.
- Add a new column to display the unit price.
Here’s an example code modification:
<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
????<thead>
????????<tr>
????????????<th class="td" scope="col"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
????????????<th class="td" scope="col"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>
????????????<th class="td" scope="col"><?php esc_html_e( 'Unit Price', 'woocommerce' ); ?></th>
????????????<th class="td" scope="col"><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
????????</tr>
????</thead>
????<tbody>
????????<?php
????????foreach ( $items as $item_id => $item ) {
????????????$product = $item->get_product();
????????????if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
?????????????????>
????????????????<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
????????????????????<td class="td" style="text-align:left; vertical-align:middle; word-wrap:break-word;"><?php
????????????????????????echo wp_kses_post( $item->get_name() );
????????????????????????// Show SKU, if enabled
????????????????????????if ( $show_sku && is_object( $product ) && $product->get_sku() ) {
????????????????????????????echo ' (#' . $product->get_sku() . ')';
????????????????????????}
????????????????????????// allow other plugins to add additional product information here
????????????????????????do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text );
????????????????????????wc_display_item_meta( $item );
????????????????????????do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
?????????????????????></td>
????????????????????<td class="td" style="text-align:left; vertical-align:middle;"><?php echo esc_html( $item->get_quantity() ); ?></td>
????????????????????<td class="td" style="text-align:left; vertical-align:middle;"><?php echo wc_price( $item->get_total() / $item->get_quantity() ); ?></td>
????????????????????<td class="td" style="text-align:left; vertical-align:middle;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
????????????????</tr>
????????????????<?php
????????????}
????????}
?????????>
????</tbody>
</table>Step 4: Save and Test
After making these changes, save the file and test it by placing an order and checking the order confirmation email.
Forum: Plugins
In reply to: [WooCommerce] Product custom permalink problemHi @bangboke ,
Step 1: Customize WooCommerce Permalinks
- Go to WordPress Dashboard: Navigate to Settings > Permalinks.
- Scroll to the WooCommerce section: Under the Product permalinks section, you should see a field that allows you to customize the base for your product URLs.
- Choose “Custom Base”: In this section, you’ll see options like:
- Default:
/product/
- Shop base:
/shop/
- Shop base with category:
/shop/%product_cat%/
- Custom base: (This is what you need.)
- Default:
- Set the Custom Base: Select the “Custom base” option and leave the field empty. If you leave it blank, WooCommerce will stop adding
/product/
before your products’ permalinks.Alternatively, you can set the custom base to/%product_cat%/
to ensure that your product URLs follow this structure directly. - Save the Changes: Click on Save Changes at the bottom of the page.
Step 2: Flush Permalinks
Sometimes, changes to permalink settings do not take effect immediately. To ensure the new structure is applied correctly:
- Flush Permalinks: After you’ve saved your custom permalink settings, WordPress should automatically flush the rewrite rules. However, if it doesn’t work right away, you can manually flush permalinks by:
- Going to Settings > Permalinks.
- Clicking Save Changes again without making any modifications to force WordPress to regenerate the permalinks.
Thank you.
Forum: Plugins
In reply to: [WooCommerce] Image size on “Short Description”Hi @hadarhacohen ,
When you set your image in a short description that time you can resize your image, that time you need to click this image and then resize it.
Thank you.Forum: Plugins
In reply to: [WooCommerce] All products categoryHi @komar132 ,
Can you reform this,
( function( wp ) {
var el = wp.element.createElement;
var InspectorControls = wp.blockEditor.InspectorControls;
var PanelBody = wp.components.PanelBody;
var SelectControl = wp.components.SelectControl;
var useSelect = wp.data.useSelect;
var Fragment = wp.element.Fragment;wp.hooks.addFilter( 'blocks.registerBlockType', 'my-plugin/extend-all-products', function( settings, name ) { if ( name === 'woocommerce/all-products' ) { settings.attributes = Object.assign( settings.attributes, { selectedCategory: { type: 'string', default: '' } }); var editFunction = settings.edit; settings.edit = function( props ) { if (props.name === 'woocommerce/all-products') { var categories = useSelect( function( select ) { return select( 'core' ).getEntityRecords( 'taxonomy', 'product_cat', { per_page: -1 } ) || []; }, [] ); var categoryOptions = categories.map( function( cat ) { return { label: cat.name, value: cat.id }; } ); categoryOptions.unshift({ label: 'Select category', value: '' }); return el( Fragment, {}, el( editFunction, props ), el( InspectorControls, {}, el( PanelBody, { title: 'Category Settings' }, el( SelectControl, { label: 'Select Category', value: props.attributes.selectedCategory || '', options: categoryOptions, onChange: function( newValue ) { props.setAttributes({ selectedCategory: newValue }); } } ) ) ) ); } return el( editFunction, props ); }; settings.save = function() { return null; // Gutenberg blocks usually return null for dynamic blocks. }; } return settings; } );
} )( window.wp );
class Utilities_Function_Kategorie {
public function __construct() { add_action('enqueue_block_editor_assets', array($this, 'enqueue_category_filter_script')); add_filter('woocommerce_blocks_product_grid_query_args', array($this, 'filter_products_by_category'), 10, 2); } public function enqueue_category_filter_script() { wp_enqueue_script( 'category-filter-block', plugins_url('category-filter.js', __FILE__), array('wp-blocks', 'wp-element', 'wp-components', 'wp-data', 'wp-editor'), filemtime(plugin_dir_path(__FILE__) . 'category-filter.js') ); } public function filter_products_by_category($query_args, $attributes) { // Debugging logs error_log('Filtering products by category with attributes: ' . print_r($attributes, true)); if (isset($attributes['selectedCategory']) && !empty($attributes['selectedCategory'])) { error_log('Selected category ID: ' . $attributes['selectedCategory']); // Ensure query is correctly updated $query_args['tax_query'][] = array( 'taxonomy' => 'product_cat', 'field' => 'term_id', // Use 'term_id' instead of 'id' for taxonomy queries 'terms' => array($attributes['selectedCategory']), 'operator' => 'IN', ); error_log('Updated query_args with tax_query: ' . print_r($query_args, true)); } else { error_log('No category selected or selectedCategory attribute is empty.'); } return $query_args; }
}
new Utilities_Function_Kategorie();
Forum: Plugins
In reply to: [WooCommerce] Css selector to style Add to Cart button blockHi @hebhansen ,
You can use this formate in your custom CSS place –
/* Default WooCommerce Add to Cart buttons */
.woocommerce a.button,
.woocommerce button.button,
.woocommerce input.button,
.woocommerce a.add_to_cart_button {
background-color: #f5f5f5;
color: #333;
}/* Apply your custom light button styles */
.my-light-button.woocommerce a.button,
.my-light-button.woocommerce button.button,
.my-light-button.woocommerce input.button,
.my-light-button.woocommerce a.add_to_cart_button {
background-color: #fff;
color: #000;
border: 1px solid #ddd;
}/* Hover effect for light buttons */
.my-light-button.woocommerce a.button:hover,
.my-light-button.woocommerce button.button:hover,
.my-light-button.woocommerce input.button:hover,
.my-light-button.woocommerce a.add_to_cart_button:hover {
background-color: #eaeaea;
color: #111;
}
Thank you.Forum: Plugins
In reply to: [WooCommerce] In Stock showing twiceHi @pudpud ,
I think it will not be compatible with plugins and themes. In this case, I think you need to deactivate the plugin one by one and check it.
Thank you.Forum: Plugins
In reply to: [WooCommerce] Missing product image and SKU in admin >products >all productsHi @osositno ,
Here I think it has conflicted with plugins or WooCommerce customization. So, make sure that you use that plugin these are compatible with woocommerce.
Thank you.Forum: Plugins
In reply to: [WooCommerce] Display the product attribute achive pageHi @wpblogwriter,
You are most welcome.Forum: Plugins
In reply to: [WooCommerce] Display the product attribute achive pageHi, @wpblogwriter
I understand your issue, if you use this plugin then I think it will be solved.
https://www.ads-software.com/plugins/woo-variation-swatches/Thank you.
Forum: Plugins
In reply to: [WooCommerce] Adding to cart process not finishing when error message shownHi @joelmellin
I think this issue was created for your timer plugin. What can you deactivate it and then check it?Forum: Plugins
In reply to: [WooCommerce] WooCommerce performance tips@thecreator01
You are most welcome.Forum: Plugins
In reply to: [WooCommerce] WooCommerce performance tipsHi, @thecreator01
Disable Unnecessary WooCommerce Features:
- Disable WooCommerce Analytics: WooCommerce’s built-in analytics can be resource-intensive. You can disable it if you use third-party analytics like Google Analytics.
- Go to WooCommerce > Settings > Advanced > WooCommerce Analytics and disable features you don’t need.
- Disable Reviews: If your store doesn’t need product reviews, turning this feature off can save some processing power.
- Go to WooCommerce > Settings > Products > General and uncheck “Enable product reviews.”
- Disable Cart Fragments: WooCommerce uses AJAX calls to update the cart without refreshing the page, but this can add overhead. Disable it if you don’t need a dynamic cart update.
- You can use a plugin like Disable Cart Fragments or add custom code.
- Disable Unused Payment Gateways: Having many payment gateways active can slow things down. Only enable the ones you actually use.
- Go to WooCommerce > Settings > Payments and disable any unnecessary gateways.
General Performance Suggestions:
- Caching: Use a caching plugin like W3 Total Cache or WP Super Cache to reduce server load by serving cached pages to users.
- Image Optimization: Compress your images with plugins like Smush or Imagify. Make sure to use next-gen formats like WebP for better performance.
- CDN: Use a Content Delivery Network (CDN) like Cloudflare or KeyCDN to speed up content delivery globally.
- Database Optimization: Regularly optimize your WordPress database with plugins like WP-Optimize to remove unnecessary data such as post revisions, drafts, and transients.
- Lazy Load Images: Enable lazy loading for images to only load them as they come into view. This is often built into modern themes or you can use plugins like Lazy Load by WP Rocket.
- Choose a Lightweight Theme: Opt for a lightweight theme like Astra or GeneratePress that is optimized for speed and minimal load.
Limit Plugins: The more plugins you use, the heavier your site becomes. Only install essential plugins, and avoid ones with overlapping functionality.
Thank you.Forum: Plugins
In reply to: [WooCommerce] Woocommerce Cart not updating properlyHi @beseenweband ,
Theme Conflict: Your theme might not be compatible with WooCommerce’s AJAX cart updating.
Outdated Template Files: WooCommerce templates within your theme might be outdated. Ensure that your theme files are up to date by navigating to: WooCommerce → Status → Templates
If you find outdated templates, you’ll need to either update the theme or manually update those WooCommerce template files.
Thank you.Forum: Plugins
In reply to: [WooCommerce] How ToHi @boionfire81
This issue create for product variation. I think after using “https://www.ads-software.com/plugins/woo-variation-swatches/” this plugin this problem will be solved
Thank you.Hello tachshitbemilel,
You can go through permalink settings page,
Flush Permalinks:
. Go to Settings > Permalinks.
. Simply click Save Changes without modifying anything. This will force
WordPress to regenerate the rewrite rules.Thank you.