OMG! I”m a GOd! I used this: http://clicknathan.com/web-design/conditional-statement-woocommerce-subscriptions/
but … the buttons are just little squares … no text.
Any ideas?
update … in the single-product/add-to-cart/single.php … i found ` <button type=”submit”
class=”single_add_to_cart_button button alt”><?php echo esc_attr($product->single_add_to_cart_text()); ?></button>`
so … i need to add the text for the link in there … but what do I put there?
<?php do_action( 'woocommerce_add_to_cart_button_text' ); ?>
^ i just made that up … i have no idea what that is.
okay .. I just added
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' ); // 2.1 +
function woo_custom_cart_button_text() {
return __( 'View Issue', 'woocommerce' );
}
i think it might have worked … i think.
no … this isn’t working at all.
crap. even if the user is not a subscriber the buttons are showing as empty.
Can you clearly explain what this view button is replacing (on which screen) and where it is going to link to?
For instance this page: http://nfldherald.stirlingpublications.com/product/issue5-jan-31-feb-16/
the button says add to cart, but i want the button to say and the link to be different if someone is signed in.
Right now I have a short code set up so that the ‘View This Issue’ button is only visible to users who are members.\
[wcm_restrict]
View Issue Button Here
[/wcm_restrict]
But i don’t want two buttons … I’d like to have one button, but the attributes change according to the users membership status.
The worst case scenario would be that I have:
[wcm_restrict]
View Issue Button Here
[/wcm_restrict]
[short code that members can't see]
Add to Cart
[/short code that members can't see]'
^ but ... I don't even know if that exists - a short code that restricts members visibility, so only non-members can see it.
WOW! I just found it: [woocommerce_members_only] Your content here for members only… [woocommerce_members_only]
[woocommerce_non_members_only] Your content for non-members only here… [woocommerce_non_members_only]
To specify membership plans, simply use parameter key (or keys for multiple keys), like this:
[woocommerce_members_only key=”silver”] Your content for members with plan Silver here… [woocommerce_members_only]
wait – i don’t think that works
Here is the new shortcode … just in case someone else is looking for it.
[wcm_nonmember]
Whoops, this video is for members only. If you have a membership, please log in. If not, you can definitely get access! Purchase a membership here.
[/wcm_nonmember]
[wcm_restrict]
Embedded video displayed to members only.
[/wcm_restrict]
but I don’t know how to put short code around the button – it’s a part of the woocommerce set up … and I can’t imagine you could use that shortcode for this case.
Are there function equivalents to those shortcodes? Then you could actually place the code within templates/single-product/add-to-cart/subscription.php
https://dl.dropboxusercontent.com/s/wtpg8u9isnihpuj/2016-02-19%20at%2012.43.png?dl=0
i don’t think so … i’ve looked. 🙁
i don’t think so … i’ve looked. 🙁
I reckon there will be – refer to the docs of the plugin which has wcm_restrict
Yeah, I found it … but it broke my site … so I had to revert.
I used this one.
if ( wc_memberships_is_product_viewing_restricted() ) {
echo 'Add To Cart Button';
} else {
echo 'View Issue Button';
}
I just put it in the functions.php by itself, just to test – should I put it in or out of the <php?