Allow only 2free D/Ls for specific membership level within a specific category?

Posted by: Wayne Philips

5th June 2020, 2:07 pm

Wayne Philips

@go6

5 Jun 2020
2:07 pm

Is this config possible out of the box, please? IF not please can you assist adding such restriction?

  • Developer
    Richard Webster

    @rwebster

    5 Jun 2020
    2:11 pm

    Hi Wayne. Something like this could be achieved by setting that membership to have a 100% discount only for those categories, and then set the membership download limit to 2.

  • Wayne Philips

    @go6

    5 Jun 2020
    5:21 pm

    The issue with that is we have 6 other membership levels and using a category is not a good solution as that will be visible on the site in various places. Is there a way to add this restriction via functions PHP code?

  • Developer
    Richard Webster

    @rwebster

    5 Jun 2020
    5:35 pm

    Hi mate the title says you want to use a category.

    You could code some PHP to do this, but you'd get the same thing with my suggestion.

  • Wayne Philips

    @go6

    13 Jun 2020
    11:20 pm

    This requirement has slightly changed... I might need help with a custom query please.

    I want to allow 2 downloads to a specific member level but only from a specific taxonomy which is linked to the team they belong to (woo commerce memberships for teams)

    Technically I have all the data accessible I just need to put it all together and set it up as a function

    This will get me the taxonomy selectoin for a users team

    $team_sectors = get_field( 'team_sectors', $teamid );
    <?php if ( $team_sectors ) : ?>
        <?php $get_terms_args = array(
            'taxonomy' => 'category',
            'hide_empty' => 0,
            'include' => $taxonomy_id,
        ); ?>
        <?php $terms = get_terms( $get_terms_args ); ?>
        <?php if ( $terms ) : ?>
            <?php foreach ( $terms as $term ) : ?>
                <a href="<?php echo esc_url( get_term_link( $term ) ); ?>"><?php echo esc_html( $term->name ); ?></a>
            <?php endforeach; ?>
        <?php endif; ?>
    <?php endif; ?>

    But I need to add in the part about which membership level they are (should match a specific level) then do the free download limit of any 2 products in that taxonomy ?

    Can you offer paid help to help finish the query?