Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2019-02-09 04:06:07

mad
Member
From: Arkansas
Registered: 2014-01-03
Posts: 154
Website

Discount codes/Bands question

Is there a way to apply a discount code or band to a specific product or does this require a separate pricing scheme setup?  If not then a future request for improvement would be to have a way to apply a discount code or band to a single product or group of products.  Let me know your thoughts or a way to do this without setting up a specific pricing scheme which would be tedious.

Offline

#2 2019-02-09 04:50:26

mad
Member
From: Arkansas
Registered: 2014-01-03
Posts: 154
Website

Re: Discount codes/Bands question

Here is how Fotomoto is doing it and It would be nice to set it up in a similar fashion but maybe more specific product category or categories (group what you want to offer).  Just a thought on a future improvement.

Coupon Type
[] Offer products at cost (no profit)
[] Offer discount ex. 10%

This coupon is valid for [dropdown list Products/Product Categories]
Coupon Restrictions
Require US Dollar
Valid from [date or no date calendar select]
Valid to [date or no date calendar select]
Valid for uses [             ]

Offline

#3 2019-03-28 03:24:39

mad
Member
From: Arkansas
Registered: 2014-01-03
Posts: 154
Website

Re: Discount codes/Bands question

Since there was no reply here, I found a solution to only have discount codes apply to a specific product and not have it displayed every time if a product does not have a discount associated with it. Let me know if anyone wants to know how I did this and I will gladly share it.

Offline

#4 2019-03-28 05:23:43

skipper
Member
Registered: 2013-04-26
Posts: 121

Re: Discount codes/Bands question

Hi,

I haven't set up a shop yet, but I am planing on doing that soon and it would interest me how you did that with the discounts!

Thanx

Offline

#5 2019-03-28 05:56:04

mad
Member
From: Arkansas
Registered: 2014-01-03
Posts: 154
Website

Re: Discount codes/Bands question

Hi,

Here is what I did first I added code to the Scripts function in the phplugins file based on the page that was being shown (i.e. ImageCart).

Example:
function scripts
{
// Determine what page you are on this can be done in many ways I chose to do it with a functions call to get the URL then determine the Page
    switch ($page)
   {
       case 'ImageCartPage':                             // whatever your page is called  [I use a variable though]
              showDiscount($page);                      // a function that I put in the plugin file above the class sets a cookie with yes or no
              break;
       case 'cart':                                             // this is the backlight cart page
              if(isset($_COOKIE[$cookie_cart_discount]))
            {
                if ($_COOKIE[$cookie_cart_discount] == 'no')         // I use yes or no from the showDiscount function
                {    // if no then I hide the discount entry field when the Cart pop-up shows
                    echo '
                        <style type="text/css">
                            .discount-entry
                            {
                                display:none;
                            }
                        </style>
                        ';
                }       
            }       
            break;
   }
}

// here is an example of the showDiscount function I use - mine is more involved
function showDiscount($page)
{
         $cookie_cart_discount = 'cartdiscount';                //  Set up a cookie name
   
    switch($page)
    {
        case 'glryimgcrt':                                // My Gallery img cart name(slug)
        case 'lmtdimgcrt':                                // My Limited Fine Art cart Name(slug)
        case 'imgcrtglry':                                // My Clients Cart Name(slug)
            $myCategory = getMyCategory();                // This is my function to get the Pricing scheme store on the MetaData Category called 'itempricing'
            if ($myCategory != '')                    // There are a few ways to get the Pricing Schemes but I added a querystring '?category='xxxxxx' where xxxx is the // pricing scheme.  But you could also read the backlight Database too or some other mechanism
            {   
                if ($page == 'glryimgcrt')               
                {        // Used an array of all the Pricing Schemes and set to yes or no depending on when I want a discount applied = yes
                    $schemes = array("Digital Downloads Multi Pricing"=>"no","Photographic Prints Pricing"=>"no","Photographic Dream Prints Pricing"=>"no","Photographic Fine Art Pricing"=>"no","Acrylic Block Pricing"=>"no","Acrylic Face Mounted Small Pricing"=>"no",...etc...etc...etc);
                }
                elseif ($page == 'lmtdimgcrt')   
                {
                    $schemes = array("Lmtd Art Print Canvas Pricing"=>"no","Lmtd Acrylic Metal Print Pricing"=>"no","Lmtd Metal Print Pricing"=>"no","Lmtd Fine Art Print Pricing"=>"no"....etc....etc...etc);
                } // etc..
                foreach($schemes as $catkey => $catvalue)
                {
                    if ($myCategory == $catkey)
                    {    // find the pricing scheme = to what is in my array and set the cookie so when the Cart pop-up is called then it can be shown or not shown
                        if ($catvalue == 'yes')
                        {
                            setcookie($cookie_cart_discount, 'yes', 0 , "/","EXAMPLE.COM",true); 
                            return true;
                        }
                        else
                        {
                            setcookie($cookie_cart_discount, 'no', 0 , "/","EXAMPLE.COM",true);
                            return false;
                        }       
                    }
                }
            }
            setcookie($cookie_cart_discount, 'no', 0 , "/","EXAMPLE.COM",true);
            break;
        default:
            break;
    }
}

If you need help with the URL or getPage functions let me know you can reach me via my site https://keylightphotography.us/contact

Hope this helps.. let me know  Using it this way I only need to change the showDiscounts function to turn on or off the Pricing schemes and republish the plugin file no other changes are required.  Makes it fast and easy.

Last edited by mad (2019-03-28 05:59:56)

Offline

#6 2019-03-28 18:49:16

skipper
Member
Registered: 2013-04-26
Posts: 121

Re: Discount codes/Bands question

Wow, thanks. I will bookmark this and get back as soon as I am ready for this.

Offline

Board footer

Powered by FluxBB