Last active
August 30, 2018 06:27
-
-
Save patrickposner/c280ea5027a97e06c447db050eec1473 to your computer and use it in GitHub Desktop.
Add additional information for customer group on single product template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'woocommerce_single_product_summary', 'rbp_output_single_product_discount_information', 35 ); | |
| function rbp_output_single_product_discount_information() { | |
| $group = get_user_meta( get_current_user_id(), 'customer_group', true ); | |
| if ( is_user_logged_in() === true && 'stammkunden' === $group ) { | |
| $product = wc_get_product( get_the_id() ); | |
| if ( $product->is_type( 'variable' ) ) { | |
| $available_variations = $product->get_available_variations(); | |
| $output = false; | |
| foreach ( $available_variations as $variation ) { | |
| $rbp_config = get_post_meta( $variation['variation_id'], 'rbp_role_config' ); | |
| if ( ! empty( $rbp_config && false === $output ) ) { | |
| foreach ( $rbp_config as $group ) { | |
| if ( 'stammkunden' == key( $group ) ) { | |
| echo '<p><b>Rabatt für Stammkunden</b><br>Unsere Stammkunden erhalten folgende Rabatte:<br>Ab 10 kg - 10% Rabatt<br>Ab 15 kg - 15% Rabatt</p>'; | |
| $output = true; | |
| } | |
| } | |
| } | |
| } | |
| } else { | |
| $rbp_config = get_post_meta( get_the_id(), 'rbp_role_config' ); | |
| foreach ( $rbp_config as $group ) { | |
| if ( 'stammkunden' == key( $group ) ) { | |
| echo '<p><b>Rabatt für Stammkunden</b><br>Unsere Stammkunden erhalten folgende Rabatte:<br>Ab 10 kg - 10% Rabatt<br>Ab 15 kg - 15% Rabatt</p>'; | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment