Woocommerce - how to display the grouped product that a simple product belongs to on it's single product page?
By : Ricardo Arosemena
Date : March 29 2020, 07:55 AM
wish of those help Thought I should mark this as answered - helgatheviking had it right - a grouped product is the post_parent of the single product page, using the global $post variable - this works to test for a grouped product on the single product page: code :
global $post;
if( $post->post_parent != 0 ){
echo 'is part of a group';
}
|
Grouped product parent vs Grouped product child in woocommerce
By : gilange
Date : March 29 2020, 07:55 AM
Any of those help Issue is that you are using Cart Functions instead of Order Functions. First you need to use wc_pb_is_bundle_container_order_item instead of wc_pb_is_bundle_container_cart_item as we are checking against Order Items. code :
<?php } else { ?>
<tr class="item">
<td width="10%" style="float:right;">
<?php echo $item['qty']; ?>
</td>
<td width="5%" style="float:right;">
<?php
// Adding a check to see if current item is a child of a container
$item_name_padding = wc_pb_is_bundled_order_item( $item ) ? '----': '';
echo $item_name_padding . $item['name'];
//echo 'i m child';
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order );
$templater->wc_display_item_meta( $item, true );
$templater->wc_display_item_downloads( $item, true );
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order );
?>
</td>
<td width="25%" style="float:right;">
<?php echo $product && $product->get_sku() ? $product->get_sku() : '-'; ?>
</td>
</tr>
<?php }} ?>
|
Add a product attribute in the product title on Woocommerce single product pages
By : user1433308
Date : March 29 2020, 07:55 AM
wish help you to fix your issue This is quiet easy using the following code that will remove the product title to replace it with a custom title including the product attribute "brand name" after it: code :
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_single_product_summary', 'custom_template_single_title', 5 );
function custom_template_single_title() {
global $product;
$brand_name = $product->get_attribute('brand-name');
echo '<h1 class="product_title entry-title">';
the_title();
if( $brand_name )
echo ' - ' . $brand_name;
echo '</h1>';
}
|
How to get the grouped product ID from a linked product in woocommerce
By : AshishK
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You can't get the product Id of a particular grouped product through one of its children product ID, as each children can be in many different grouped products. The only data that define the children products IDS for a grouped product is located in wp_postmeta table arround the meta_key _children as an array of children product IDs. code :
function get_parent_grouped_id( $children_id ){
global $wpdb;
$results = $wpdb->get_col("SELECT post_id FROM {$wpdb->prefix}postmeta
WHERE meta_key = '_children' AND meta_value LIKE '%$children_id%'");
// Will only return one product Id or false if there is zero or many
return sizeof($results) == 1 ? reset($results) : false;
}
$parent_grouped_id = get_parent_grouped_id( 738 );
$grouped_products = wc_get_products( array( 'limit' => -1, 'type' => 'grouped' ) );
$ids = wc_get_products( array( 'limit' => -1, 'type' => 'grouped', 'return' => 'ids' ) );
|
How can I check if a product is part of a grouped product (WooCommerce)
By : Felix Michael
Date : March 29 2020, 07:55 AM
With these it helps Currently my function only checks if the product is type 'external' before execution, how can I change the function to check if the product is part of a 'grouped' woocommerce product. Then echo the button which contains the parent product permalink which has already been configured. , I think this might work but will have to test it.
|