Forums / General Questions / gift certificates with Special

gift certificates with Special

Views: 2,188

Results 1 to 16 of 16
4 Nov 2012, 11:46 PM
#1
awesomshot avatar

awesomshot

New Zenner

Join Date:
Aug 2012
Posts:
10
Plugin Contributions:
0

gift certificates with Special

How do I setup a gift certificate that costs $10 but has a value of $20? I haven't been able to find an answer in the gift certificate forms

5 Nov 2012, 3:35 PM
#3
awesomshot avatar

awesomshot

New Zenner

Join Date:
Aug 2012
Posts:
10
Plugin Contributions:
0

Re: gift certificates with Special

Thanks for the response, but that does not help me. That document does not tell me how to make the gift certificate's value different from the price. I was able to install a functioning gift certificate. That was not my problem. I would like to know how to establish a gift card that has a value of $20, but cost $10. So far all of my attempts at establishing this type of card has failed. My Gift Certificate Release Queue shows my customers only have the $10 they paid for the card available.

5 Nov 2012, 4:09 PM
#4
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: gift certificates with Special

There's no way I know of to do that within Zencart. You would need to write code.

5 Nov 2012, 4:15 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: gift certificates with Special

One work around is to make a Product that does not have the model starting with GIFT and mark as a Virtual Product then have the customer order that Product and you then send them a Gift Certificate via your Zen Cart Admin for the amount you want them to have based on what they actually purchase ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Nov 2012, 9:58 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: gift certificates with Special

Glad that this is working for you ... thanks for the update ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

3 May 2013, 12:50 AM
#8
dan123 avatar

dan123

New Zenner

Join Date:
Apr 2008
Posts:
82
Plugin Contributions:
0

Re: gift certificates with Special

Ajeh thanks for your help, I was looking for it. However I still feel insecure about this method, can some kind of validation be added to check if customer is not trying to buy this virtual product with credit he already has? For example add model - "SaveCard" to the product and check for it during checkout, if it is found no go. Well, just like Zen Cart works with regular GIFT certificates?

I already started digging into it, I tried to add:

	
$products = $_SESSION['cart']->get_products();
	foreach ($products as $product) {
            if (!is_product_valid_redeem($product['id'])) {
				$messageStack->add_session('checkout_payment', ERROR_NO_INVALID_REDEEM_GV, error);
				zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
            }        
          }

to ot_gv.php file(in function collect_posts()) and function is_product_valid_redeem to functions_general.php

function is_product_valid_redeem($product_id) {
    global $db;
    $product_query = "SELECT products_model FROM " . TABLE_PRODUCTS . "
                      WHERE products_id = '" . (int)$product_id . "'";

    $product = $db->Execute($product_query);

	if (preg_match('/^SAVECARD/', $product->fields['products_model'])) {
      return false;
    }
}

But it is not working, can somebody help me figure out what is missing?

Thank you!

3 May 2013, 1:19 AM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: gift certificates with Special

I am working on something for allowing Gift Certificates on Special but prevent the purchase of Gift Certificates with Gift Certificates so that you do not end up with a loop of buy/sell that costs more money than you want to give on a Gift Certificate with a Special ...

There is a way to do this but it will take a while for me to work out all the issues and safeties ...

It requires quite a few changes ... but I have a plan ... :lookaroun

But it will be sometime late next week before I have this working and tested out ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

3 May 2013, 6:59 AM
#10
dan123 avatar

dan123

New Zenner

Join Date:
Apr 2008
Posts:
82
Plugin Contributions:
0

Re: gift certificates with Special

Great! If you will need any help testing or whatever just let me know!
Thanks!

16 May 2013, 9:01 PM
#11
dan123 avatar

dan123

New Zenner

Join Date:
Apr 2008
Posts:
82
Plugin Contributions:
0

Re: gift certificates with Special

Hi Linda!

Have you had time to look into the Gift Certificates on Special? If not, can you advise where I should start.

Thank you,
Dan!

17 May 2013, 12:03 AM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: gift certificates with Special

Okay ... this will be more fun for you than it was for me to figure this all out with the least amount of code changes and still work correctly without you losing your shirt by having GVs with Specials and allowing them to be purchased at a discounted price ... :lookaroun

NOTE: This work around is designed for Placing Gift Certificates on SPECIAL (NOT SALE using Salemaker) and to NOT allow GVs to purchase GVs

In order to make GVs not purchase GVs, there needs to be some customization to the Order Totals module for Gift Certificates ot_gv.php
/includes/modules/order_total/ot_gv.php

Find the function get_order_total and add the code in RED:

  function get_order_total() {
    global $order;
    $order_total = $order->info['total'];
    // if we are not supposed to include tax in credit calculations, subtract it out
    if ($this->include_tax != 'true') $order_total -= $order->info['tax'];
    // if we are not supposed to include shipping amount in credit calcs, subtract it out
    if ($this->include_shipping != 'true') $order_total -= $order->info['shipping_cost'];
    $order_total = $order->info['total'];

[B]// bof: check gv_amount in cart and not allow GVs to pay for GVs
    $chk_gv_amount = 0;
    $chk_products = $_SESSION['cart']->get_products();
  for ($i=0, $n=sizeof($chk_products); $i<$n; $i++) {
    if (preg_match('/^GIFT/', addslashes($chk_products[$i]['model']))) {
      // determine how much GV was purchased
      $chk_gv_amount += ($chk_products[$i]['price'] * $chk_products[$i]['quantity']);
        }
    }
    // reduce Order Total less GVs
    $order_total = ($order_total - $chk_gv_amount);
//echo 'GV chk_gv_amount: ' . $chk_gv_amount . ' $order_total: ' . $order_total . '<br>';
// eof: check gv_amount in cart and not allow GVs to pay for GVs
[/B]    
    return $order_total;
  }

In the default Zen Cart Code, GVs cannot be placed on Special because they are a "unique" kind of Product ...

However, there is a work around ...

Make your Gift Certificate that you want to put on Special as you normally would but do NOT assign its Product Model yet, leave that blank ...

Next, Place this Gift Certificate on Special ...

Now, Edit the Product and give it ist proper Product Model that starts with:
GIFT

Finally, test this out ...

Make sure that your regular GVs and GVs on Special are able to be purchased properly with Check/Money Order, PayPal, etc. ... I think I have all of this working right based on this post ...

NOTE: Remember, to place a GV Product on SPECIAL you will need to CHANGE its Product Model to be BLANK then EDIT it to be correct with the GIFTsomethinghere ...

Let us know how this works for you ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

19 May 2013, 5:28 AM
#13
dan123 avatar

dan123

New Zenner

Join Date:
Apr 2008
Posts:
82
Plugin Contributions:
0

Re: gift certificates with Special

Linda, thank you for your fast reply.

I have been playing with it for some time now and probably am missing something. Whenever I purchase the certificate, value $100 special 10%, for $90, from the admin panel I can only release this certificate for $90 as well, not $100. Did I miss something?

Thank you!

19 May 2013, 1:48 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: gift certificates with Special

Let me check if I did ... :lookaroun

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

19 May 2013, 4:41 PM
#15
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: gift certificates with Special

Okay ...

Rule 1 - do not use Specials on GVs that are Priced by Attributes

Rule 2 - do not use SALE (SaleMaker) on GVs if you do, those SALES should all be ignored

More code changes to:
/includes/modules/order_total/ot_gv.php

Replace the function update_credit_account with:

  function update_credit_account($i) {
    global $db, $order, $insert_id;
    // only act on newly-purchased gift certificates
    if (preg_match('/^GIFT/', addslashes($order->products[$i]['model']))) {
      // determine how much GV was purchased
      // check if GV was purchased on Special
      $gv_original_price = zen_products_lookup((int)$order->products[$i]['id'], 'products_price');
         // if prices differ assume Special ang get Special Price
         // Do not use this on GVs Priced by Attribute
      if ($gv_original_price != $order->products[$i]['final_price'] && !zen_get_products_price_is_priced_by_attributes((int)$order->products[$i]['id'])) {
          $gv_order_amount = ($gv_original_price * $order->products[$i]['qty']);
      } else {
          $gv_order_amount = ($order->products[$i]['final_price'] * $order->products[$i]['qty']);
        }
      // if tax is to be calculated on purchased GVs, calculate it
      if ($this->credit_tax=='true') $gv_order_amount = $gv_order_amount * (100 + $order->products[$i]['tax']) / 100;
      $gv_order_amount = $gv_order_amount * 100 / 100;

      if (MODULE_ORDER_TOTAL_GV_QUEUE == 'false') {
        // GV_QUEUE is false so release amount to account immediately
        $gv_result = $this->user_has_gv_account($_SESSION['customer_id']);
        $customer_gv = false;
        $total_gv_amount = 0;
        if ($gv_result) {
          $total_gv_amount = $gv_result;
          $customer_gv = true;
        }
        $total_gv_amount = $total_gv_amount + $gv_order_amount;
        if ($customer_gv) {
          $db->Execute("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $total_gv_amount . "' where customer_id = '" . (int)$_SESSION['customer_id'] . "'");
        } else {
          $db->Execute("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . (int)$_SESSION['customer_id'] . "', '" . $total_gv_amount . "')");
        }
      } else {
        // GV_QUEUE is true - so queue the gv for release by store owner
        $db->Execute("insert into " . TABLE_COUPON_GV_QUEUE . " (customer_id, order_id, amount, date_created, ipaddr) values ('" . (int)$_SESSION['customer_id'] . "', '" . (int)$insert_id . "', '" . $gv_order_amount . "', NOW(), '" . $_SERVER['REMOTE_ADDR'] . "')");
      }
    }
  }

NOTE: You really need to test all of the code very carefully on allowing Specials on GVs as right now it is pretty experimental and I will probably get shot by the rest of the Zen Cart Team for heading in this direction with GVs to allow Specials ... :blink:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

20 May 2013, 5:46 AM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: gift certificates with Special

Okay ...

Rule 1 - do not use Specials on GVs that are Priced by Attributes

Rule 2 - do not use SALE (SaleMaker) on GVs if you do, those SALES should all be ignored

More code changes to:
/includes/modules/order_total/ot_gv.php

Replace the function update_credit_account with:

  /**
   * queue or release newly-purchased GV's
   */
  function update_credit_account($i) {
    global $db, $order, $insert_id;
    // only act on newly-purchased gift certificates
    if (preg_match('/^GIFT/', addslashes($order->products[$i]['model']))) {
      // determine how much GV was purchased
      // check if GV was purchased on Special
      $gv_original_price = zen_products_lookup((int)$order->products[$i]['id'], 'products_price');
         // if prices differ assume Special ang get Special Price
         // Do not use this on GVs Priced by Attribute
      if ($gv_original_price != 0 && $gv_original_price != $order->products[$i]['final_price'] && !zen_get_products_price_is_priced_by_attributes((int)$order->products[$i]['id'])) {
          $gv_order_amount = ($gv_original_price * $order->products[$i]['qty']);
      } else {
          $gv_order_amount = ($order->products[$i]['final_price'] * $order->products[$i]['qty']);
        }
      // if tax is to be calculated on purchased GVs, calculate it
      if ($this->credit_tax=='true') $gv_order_amount = $gv_order_amount * (100 + $order->products[$i]['tax']) / 100;
      $gv_order_amount = $gv_order_amount * 100 / 100;

      if (MODULE_ORDER_TOTAL_GV_QUEUE == 'false') {
        // GV_QUEUE is false so release amount to account immediately
        $gv_result = $this->user_has_gv_account($_SESSION['customer_id']);
        $customer_gv = false;
        $total_gv_amount = 0;
        if ($gv_result) {
          $total_gv_amount = $gv_result;
          $customer_gv = true;
        }
        $total_gv_amount = $total_gv_amount + $gv_order_amount;
        if ($customer_gv) {
          $db->Execute("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $total_gv_amount . "' where customer_id = '" . (int)$_SESSION['customer_id'] . "'");
        } else {
          $db->Execute("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . (int)$_SESSION['customer_id'] . "', '" . $total_gv_amount . "')");
        }
      } else {
        // GV_QUEUE is true - so queue the gv for release by store owner
        $db->Execute("insert into " . TABLE_COUPON_GV_QUEUE . " (customer_id, order_id, amount, date_created, ipaddr) values ('" . (int)$_SESSION['customer_id'] . "', '" . (int)$insert_id . "', '" . $gv_order_amount . "', NOW(), '" . $_SERVER['REMOTE_ADDR'] . "')");
      }
    }
  }

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!