WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Simple Paypal Shopping Cart
[resolved] Get category of products (6 posts)

  1. mishli
    Member
    Posted 1 year ago #

    Hello,

    I'm trying to apply a discount for product of specific category by adding the paypal 'discount_rate_cart' input on to that category.
    It is working great when added but it applies to all purchases.
    I would like to make it apply only on products in specific category.

    Is that possible ??

    Thanks

    http://wordpress.org/extend/plugins/wordpress-simple-paypal-shopping-cart/

  2. mra13
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Mishli, The simple shopping cart plugin doesn't have a category based discount feature. So I am guessing you made some custom tweaks yourself to make this happen. Can't you add a check in the code that you added to only execute when it matches your category condition?

  3. mishli
    Member
    Posted 1 year ago #

    Thanks for the reply.

    I've just managed to do it in a similar way to what you suggested.
    Works great for me. If anyone would like the code I can share it here just let me know.

  4. mra13
    Member
    Plugin Author

    Posted 1 year ago #

    Please share the code so I can take a look too.

  5. mishli
    Member
    Posted 1 year ago #

    $price = get_post_meta( $book->ID, "price", true );
    $discount_price = round($price*0.80);
    
    $categoriesList = get_the_term_list( $book->ID, "category" , "", ' ', "" );
    $catObj = get_category_by_slug($categoriesList);
    $cat_id = $catObj->term_id;
    
     if  ($cat_id == 1)
    	echo print_wp_cart_button_for_product("$book_title", "$discount_price", 0.0001 );
    else
    	echo print_wp_cart_button_for_product("$book_title", "$price", 0.0001 );
  6. mra13
    Member
    Plugin Author

    Posted 1 year ago #

    Thank you

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.