Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter riew

    (@riew)

    Hi Roxy

    Thanks! I actually looked at those but could only find the option of selling access to a lot of content on a user level basis – not to match a product with access to specific content.

    But meanwhile I got the “Protected Content Packages For WooCommerce” plugin to work. The error was my mistake. :o)

    So problem is solved.

    But thanks! If I end up having problems with the “Protected Packages” plugin I will definately have a closer look at WooCommerce Memberships and Ultimate Memberships. Thanks for taking the time to point me towards a solution.

    Have a great day! :o)

    Kind regards
    Rie

    Thread Starter riew

    (@riew)

    Hahahahaha!! That was too stupid!! :os

    I tried everything; went into Chrome incognito browser, F12+rightclick -> clear cache, not logged in, and I just kept having access to my hidden pages.

    Why on earth didn’t it work?

    Because somehow I was still logged in as admin!!
    Don’t know how that could happen in new incognito window after logout, but apparently it could…!

    So now I am only left with text edit issues. I can fix those.

    Yay!! :oD

    Let me know if you make a premium version. I would definitely support you getting paid to keep this plugin working. :o)
    (You can write it as a comment in WordPress to those who have it installed – then I’ll see it. I won’t be letting go of this plugin.)

    Thread Starter riew

    (@riew)

    Thanks for the suggestion! :o)

    I would prefer not to install a plugin; I have a feeling that this can be done with a few lines of code… I just need to add the value from the dropdown to my link. :o)

    I use this code to display the price of each variation in the dropdown:

    
    add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' );
    
    function display_price_in_variation_option_name( $term ) {
    global $wpdb, $product;
    
    $result = $wpdb->get_col( "SELECT slug FROM {$wpdb->prefix}terms WHERE name = '$term'" );
    
    $term_slug = ( !empty( $result ) ) ? $result[0] : $term;
    
    $query = "SELECT postmeta.post_id AS product_id
    FROM {$wpdb->prefix}postmeta AS postmeta
    LEFT JOIN {$wpdb->prefix}posts AS products ON ( products.ID = postmeta.post_id )
    WHERE postmeta.meta_key LIKE 'attribute_%'
    AND postmeta.meta_value = '$term_slug'
    AND products.post_parent = $product->id";
    
    $variation_id = $wpdb->get_col( $query );
    
    $parent = wp_get_post_parent_id( $variation_id[0] );
    
    if ( $parent > 0 ) {
    $_product = new WC_Product_Variation( $variation_id[0] );
    
    $itemPrice = strip_tags (woocommerce_price( $_product->get_price() ));
    //this is where you can actually customize how the price is displayed
    return $term . ' (' . $itemPrice . ')';
    }
    return $term;
    }
    

    Can’t I grab some information (chosen ID) from this dropdown and add it to the “View product” button? The code for that button is:

    
    function mycode_add_more_details_button_to_single() {
    	add_action( 'woocommerce_after_shop_loop_item', 'mycode_display_more_details_button_to_single' );
    }
    
    add_action( 'init', 'mycode_add_more_details_button_to_single' );
    
    function mycode_display_more_details_button_to_single() {
    
    	global $product;
    
    	$url   = $product->get_permalink();
    	$text  = __( 'Se varen', 'mycode' );
    	$title = sprintf( __( 'Se mere om %s', 'mycode' ), $product->get_name() );
    	$class = sprintf( 'button add_to_cart_button product_type_%s', $product->get_type() );
    
    	$format = '<a href="%1$s" title="%2$s" class="single_add_to_cart_button button alt">%4$s</a>';
    
    	printf( $format, esc_url( $url ), esc_attr( $title ), esc_attr( $class ), esc_html( $text ) );
    }
    

    Any ideas…? :o)

    Thread Starter riew

    (@riew)

    Marking as closed. Thank you! :o)

    Thread Starter riew

    (@riew)

    This is perfect – worked like a charm!

    Thank you so much for your fast help! :o)

Viewing 5 replies - 1 through 5 (of 5 total)