Zen Cart Logo
Forums / All Other Contributions/Addons / My Add-On for MAP (minimum advertised price).

My Add-On for MAP (minimum advertised price).

Views: 32,936

Results 101 to 120 of 121
6 Feb 2021, 3:31 PM
#101
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

My Add-On for MAP (minimum advertised price).

wsworx:

The Plugin still displays etc but the quantity discounts displayed below the pricing show the lower price that is not supposed to be shown.

If you're using MAP pricing then you're probably requiring customers to add-to-cart to see the price, so therefore you don't want the discounts box to show at all;
therefore, you can cause it to no longer display by editing:
/includes/templates/YOUR_TEMPLATE_DIRECTORY/templates/tpl_product_info_display.php
You could remove the entire following section of code, or you could just make the change in red:

<!--bof Quantity Discounts table -->
<?php
  if ([B]false && [/B]$products_discount_type != 0) { ?>
<?php
/**
 * display the products quantity discount
 */
 require($template->get_template_dir('/tpl_modules_products_quantity_discounts.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_products_quantity_discounts.php'); ?>
<?php
  }
?>
<!--eof Quantity Discounts table -->
3 May 2022, 7:01 PM
#102
muah avatar

muah

Zen Follower

Join Date:
Dec 2008
Location:
USA, North East
Posts:
226
Plugin Contributions:
0

Re: My Add-On for MAP (minimum advertised price).

Suggestion, This is the kind of item that should automatically part of Zen as thanks to Amazon, Map pricing now pretty much enforced across the board.

3 May 2022, 7:37 PM
#103
muah avatar

muah

Zen Follower

Join Date:
Dec 2008
Location:
USA, North East
Posts:
226
Plugin Contributions:
0

Re: My Add-On for MAP (minimum advertised price).

Should I be overwriting the newer code with this older code. For example, the update_product.php file has more code in the newer zen version than does the MAP file of the same name. Is overwriting safe to do?

4 May 2022, 12:16 PM
#104
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,102
Plugin Contributions:
56

Re: My Add-On for MAP (minimum advertised price).

muah:

Should I be overwriting the newer code with this older code. For example, the update_product.php file has more code in the newer zen version than does the MAP file of the same name. Is overwriting safe to do?
Absolutely not! :no: You'll need to perform a file-compare (using a program like WinMerge or Beyond Compare) to merge the MAP changes into that updated version.

4 May 2022, 11:21 PM
#105
muah avatar

muah

Zen Follower

Join Date:
Dec 2008
Location:
USA, North East
Posts:
226
Plugin Contributions:
0

Re: My Add-On for MAP (minimum advertised price).

lat9:

Absolutely not! :no: You'll need to perform a file-compare (using a program like WinMerge or Beyond Compare) to merge the MAP changes into that updated version.
MAP VERSION: if ($_POST['image_delete'] == 1) {
Zen version: if (isset($_POST['image_delete']) && $_POST['image_delete'] == '1') {

a number of these types of variations, in this case I remove the zen version and replace it with the MAP version of the code?

5 May 2022, 12:17 AM
#106
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,798
Plugin Contributions:
22

Re: My Add-On for MAP (minimum advertised price).

muah:

MAP VERSION: if ($_POST['image_delete'] == 1) {
Zen version: if (isset($_POST['image_delete']) && $_POST['image_delete'] == '1') {

a number of these types of variations, in this case I remove the zen version and replace it with the MAP version of the code?

No, you do just the opposite - assume ZC code is new and improved. And you only merge the parts that are directly related to the plugin you're installing, meaning the line that mentions MAP or the entire block of code that is about MAP (it's usually commented). In the case of update_product.php file, it's literally just 2 lines of code that need to be added. Here's the entire file for you, you can use it to understand how it's done:

<?php

/**
 * @copyright Copyright 2003-2020 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: DrByte 2020 Jul 01 Modified in v1.5.7a $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
if (isset($_GET['pID'])) {
  $products_id = zen_db_prepare_input($_GET['pID']);
}
if (isset($_POST['edit']) && $_POST['edit'] == 'edit') {
  $action = 'new_product';
} elseif ((isset($_POST['products_model']) ? $_POST['products_model'] : '') . (isset($_POST['products_url']) ? implode('', $_POST['products_url']) : '') . (isset($_POST['products_name']) ? implode('', $_POST['products_name']) : '') . (isset($_POST['products_description']) ? implode('', $_POST['products_description']) : '') != '') {
  $products_date_available = zen_db_prepare_input($_POST['products_date_available']);
  if (DATE_FORMAT_DATE_PICKER != 'yy-mm-dd' && !empty($products_date_available)) {
    $local_fmt = zen_datepicker_format_fordate(); 
    $dt = DateTime::createFromFormat($local_fmt, $products_date_available);
    $products_date_available = 'null';
    if (!empty($dt)) {
      $products_date_available = $dt->format('Y-m-d'); 
    }
  }
  $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';

  // Data-cleaning to prevent data-type mismatch errors:
  $sql_data_array = array(
    'products_quantity' => convertToFloat($_POST['products_quantity']),
	'map_enabled' => zen_db_prepare_input((int)$_POST['map_enabled']),
    'map_price' => convertToFloat($_POST['map_price']),
    'products_type' => (int)$_POST['product_type'],
    'products_model' => zen_db_prepare_input($_POST['products_model']),
    'products_price' => convertToFloat($_POST['products_price']),
    'products_date_available' => $products_date_available,
    'products_weight' => convertToFloat($_POST['products_weight']),
    'products_status' => (int)$_POST['products_status'],
    'products_virtual' => (int)$_POST['products_virtual'],
    'products_tax_class_id' => (int)$_POST['products_tax_class_id'],
    'manufacturers_id' => (int)$_POST['manufacturers_id'],
    'products_quantity_order_min' => convertToFloat($_POST['products_quantity_order_min']) == 0 ? 1 : convertToFloat($_POST['products_quantity_order_min']),
    'products_quantity_order_units' => convertToFloat($_POST['products_quantity_order_units']) == 0 ? 1 : convertToFloat($_POST['products_quantity_order_units']),
    'products_priced_by_attribute' => (int)$_POST['products_priced_by_attribute'],
    'product_is_free' => (int)$_POST['product_is_free'],
    'product_is_call' => (int)$_POST['product_is_call'],
    'products_quantity_mixed' => (int)$_POST['products_quantity_mixed'],
    'product_is_always_free_shipping' => (int)$_POST['product_is_always_free_shipping'],
    'products_qty_box_status' => (int)$_POST['products_qty_box_status'],
    'products_quantity_order_max' => convertToFloat($_POST['products_quantity_order_max']),
    'products_sort_order' => (int)$_POST['products_sort_order'],
    'products_discount_type' => (int)$_POST['products_discount_type'],
    'products_discount_type_from' => (int)$_POST['products_discount_type_from'],
    'products_price_sorter' => convertToFloat($_POST['products_price_sorter']),
  );

  $db_filename = zen_limit_image_filename($_POST['products_image'], TABLE_PRODUCTS, 'products_image');
  $sql_data_array['products_image'] = zen_db_prepare_input($db_filename);
  $new_image = 'true';

  // when set to none remove from database
  // is out dated for browsers use radio only
  if (isset($_POST['image_delete']) && $_POST['image_delete'] == '1') {
    $sql_data_array['products_image'] = '';
    $new_image = 'false';
  }

  if ($action == 'insert_product') {
    $sql_data_array['products_date_added'] = 'now()';
    $sql_data_array['master_categories_id'] = (int)$current_category_id;

    zen_db_perform(TABLE_PRODUCTS, $sql_data_array);
    $products_id = zen_db_insert_id();

    // reset products_price_sorter for searches etc.
    zen_update_products_price_sorter($products_id);

    $db->Execute("INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id)
                  VALUES (" . (int)$products_id . ", " . (int)$current_category_id . ")");

    zen_record_admin_activity('New product ' . (int)$products_id . ' added via admin console.', 'info');

    ///////////////////////////////////////////////////////
    //// INSERT PRODUCT-TYPE-SPECIFIC *INSERTS* HERE //////
    ////    *END OF PRODUCT-TYPE-SPECIFIC INSERTS* ////////
    ///////////////////////////////////////////////////////
  } elseif ($action == 'update_product') {
    $sql_data_array['products_last_modified'] = 'now()';
    $sql_data_array['master_categories_id'] = (!empty($_POST['master_category']) && (int)$_POST['master_category'] > 0 ? (int)$_POST['master_category'] : (int)$_POST['master_categories_id']);

    zen_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = " . (int)$products_id);

    zen_record_admin_activity('Updated product ' . (int)$products_id . ' via admin console.', 'info');

    // reset products_price_sorter for searches etc.
    zen_update_products_price_sorter((int)$products_id);

    ///////////////////////////////////////////////////////
    //// INSERT PRODUCT-TYPE-SPECIFIC *UPDATES* HERE //////


    ////    *END OF PRODUCT-TYPE-SPECIFIC UPDATES* ////////
    ///////////////////////////////////////////////////////
  }

  $languages = zen_get_languages();
  for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
    $language_id = $languages[$i]['id'];

    $sql_data_array = array(
      'products_name' => zen_db_prepare_input($_POST['products_name'][$language_id]),
      'products_description' => zen_db_prepare_input($_POST['products_description'][$language_id]),
      'products_url' => zen_db_prepare_input($_POST['products_url'][$language_id]));

    if ($action == 'insert_product') {
      $insert_sql_data = array(
        'products_id' => (int)$products_id,
        'language_id' => (int)$language_id);

      $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

      zen_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
    } elseif ($action == 'update_product') {
      zen_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = " . (int)$products_id . " and language_id = " . (int)$language_id);
    }
  }

  $zco_notifier->notify('NOTIFY_MODULES_UPDATE_PRODUCT_END', array('action' => $action, 'products_id' => $products_id));

  zen_redirect(zen_href_link(FILENAME_CATEGORY_PRODUCT_LISTING, 'cPath=' . $cPath . '&pID=' . $products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . (isset($_POST['search']) ? '&search=' . $_POST['search'] : '')));
} else {
  $messageStack->add_session(ERROR_NO_DATA_TO_SAVE, 'error');
  zen_redirect(zen_href_link(FILENAME_CATEGORY_PRODUCT_LISTING, 'cPath=' . $cPath . '&pID=' . $products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . (isset($_POST['search']) ? '&search=' . $_POST['search'] : '')));
}

/**
 * NOTE: THIS IS HERE FOR BACKWARD COMPATIBILITY. The function is properly declared in the functions files instead.
 * Convert value to a float -- mainly used for sanitizing and returning non-empty strings or nulls
 * @param int|float|string $input
 * @return float|int
 */
if (!function_exists('convertToFloat')) {

  function convertToFloat($input = 0) {
    if ($input === null) {
      return 0;
    }
    $val = preg_replace('/[^0-9,\.\-]/', '', $input);
    // do a non-strict compare here:
    if ($val == 0) {
      return 0;
    }

    return (float)$val;
  }

}
15 Dec 2022, 9:18 PM
#107
dsc7050 avatar

dsc7050

New Zenner

Join Date:
Sep 2018
Location:
UUSA
Posts:
44
Plugin Contributions:
0

Re: My Add-On for MAP (minimum advertised price).

This is Module support zc 1.5.8?

26 Dec 2022, 4:01 AM
#108
jimmie avatar

jimmie

Totally Zenned

Join Date:
Jan 2013
Location:
New Port Richey, Florida
Posts:
971
Plugin Contributions:
0

Re: My Add-On for MAP (minimum advertised price).

how do i make this work, ```
if ($is_map_enabled == 0 && $products_discount_type != 0) { ?>

19 Jan 2024, 3:04 AM
#109
clam_man avatar

clam_man

New Zenner

Join Date:
Jun 2019
Location:
Austin TX
Posts:
65
Plugin Contributions:
0

Re: My Add-On for MAP (minimum advertised price).

Has anyone come up with a solution for an add-to-cart to see price for 1.5.8a? I looked through the stock settings and didn't see anything. I'm migrating/updating a site and its database to this newer version from 1.5.6b and I still have the data from the old database for which products have MAP turned on. I understand that just hiding the price on the front-end via JS will not keep bots from crawling the site and seeing/saving the price info so I know I'll have to make this change in the PHP. If there is no solution at the moment then can someone answer for me if the product_info template file is the one I would need to make modifications to in order to get the desired behavior? I'm using a non-stock template so I don't think my solution will be of value here but I can post what I learned and if I have some extra time I can go through the stock template file and post a solution for that. My only worry is data not posting correctly to the shopping cart but I'm sure I can figure that out if I come across it. All I am trying to do is have the template populate an 'add-to-cart for price' button where it normally populates with the price if the products table has a 1 in map_enabled for that individual products that it is querying. Thanks in advance!

5 Feb 2024, 8:46 AM
#110
clam_man avatar

clam_man

New Zenner

Join Date:
Jun 2019
Location:
Austin TX
Posts:
65
Plugin Contributions:
0

Re: My Add-On for MAP (minimum advertised price).

Well I've come up with a working solution to this issue on ZC 1.5.8a. I modified the products table in the database, the tpl_product_info_display.php, the collect_info.php, and the update_product.php files in order to get 'Add to Cart to View Price' functionality working. I have never published a plugin before for Zen Cart, so it may take me a bit to figure out how that all works but is anyone interested in this before I spend the time adapting the solution for the vanilla files?

11 May 2024, 5:43 AM
#111
muah avatar

muah

Zen Follower

Join Date:
Dec 2008
Location:
USA, North East
Posts:
226
Plugin Contributions:
0

Re: My Add-On for MAP (minimum advertised price).

Does it work in Zen version 2.0... is the question.
Without this function, I must turn off 300 products from the site which require MAP.
Frustration...

25 May 2024, 3:48 AM
#112
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: My Add-On for MAP (minimum advertised price).

muah:

Does it work in Zen version 2.0... is the question.
Without this function, I must turn off 300 products from the site which require MAP.
Frustration...
I've just submitted an update for v2.0.0

28 May 2024, 9:47 PM
#113
dsc7050 avatar

dsc7050

New Zenner

Join Date:
Sep 2018
Location:
UUSA
Posts:
44
Plugin Contributions:
0

Re: My Add-On for MAP (minimum advertised price).

DrByte:

I've just submitted an update for v2.0.0

we running this issue, can you help?

ZC: 2.0.1
PHP: 8.3

[28-May-2024 17:39:31 America/New_York] Request URI: /qwert-dVy-siGht/index.php?cmd=product&action=new_product, IP address: 99.52.339.99
--> PHP Fatal error: Uncaught Error: Undefined constant "TEXT_PRODUCTS_PRICE_EXCL" in /homepages/29/016/htdocs/DIY2024/qwert-dVy-siGht/includes/modules/collect_info.php:300
Stack trace:
#0 /homepages/29/016/htdocs/DIY2024/qwert-dVy-siGht/product.php(111): require()
#1 /homepages/29/016/htdocs/DIY2024/qwert-dVy-siGht/index.php(16): require('/homepages/29/d...')
#2 {main}
thrown in /homepages/29/016/htdocs/DIY2024/qwert-dVy-siGht/includes/modules/collect_info.php on line 300.

28 May 2024, 10:24 PM
#114
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,717
Plugin Contributions:
56

Re: My Add-On for MAP (minimum advertised price).

This define should be in admin/includes/languages/english/lang.product.php.
Check that you haven't overwritten that file with an older copy.

29 May 2024, 2:06 PM
#115
dsc7050 avatar

dsc7050

New Zenner

Join Date:
Sep 2018
Location:
UUSA
Posts:
44
Plugin Contributions:
0

Re: My Add-On for MAP (minimum advertised price).

swguy:

This define should be in admin/includes/languages/english/lang.product.php.
Check that you haven't overwritten that file with an older copy.

**No..doesn't overwritten that file.

ZC2.0.1 it's fresh install, No other plugin installed.

29 May 2024, 2:15 PM
#116
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,102
Plugin Contributions:
56

Re: My Add-On for MAP (minimum advertised price).

dsc7050:

we running this issue, can you help?

ZC: 2.0.1
PHP: 8.3

[28-May-2024 17:39:31 America/New_York] Request URI: /qwert-dVy-siGht/index.php?cmd=product&action=new_product, IP address: 99.52.339.99
--> PHP Fatal error: Uncaught Error: Undefined constant "TEXT_PRODUCTS_PRICE_EXCL" in /homepages/29/016/htdocs/DIY2024/qwert-dVy-siGht/includes/modules/collect_info.php:300
Stack trace:
#0 /homepages/29/016/htdocs/DIY2024/qwert-dVy-siGht/product.php(111): require()
#1 /homepages/29/016/htdocs/DIY2024/qwert-dVy-siGht/index.php(16): require('/homepages/29/d...')
#2 {main}
thrown in /homepages/29/016/htdocs/DIY2024/qwert-dVy-siGht/includes/modules/collect_info.php on line 300.

Line 300 of the as-distributed /admin/includes/modules/collect_info.php reads

      <label class="radio-inline"><?php echo zen_draw_radio_field('products_virtual', '0', ($pInfo->products_virtual == 0)) . TEXT_PRODUCT_NOT_VIRTUAL; ?></label>

swguy:

This define should be in admin/includes/languages/english/lang.product.php.
Check that you haven't overwritten that file with an older copy.

Noting that the definition TEXT_PRODUCTS_PRICE_EXCL isn't provided in v2.0.1, nor is it used.

dsc7050:

**No..doesn't overwritten that file.

ZC2.0.1 it's fresh install, No other plugin installed.
Where did your fresh install come from?

29 May 2024, 2:57 PM
#117
dsc7050 avatar

dsc7050

New Zenner

Join Date:
Sep 2018
Location:
UUSA
Posts:
44
Plugin Contributions:
0

Re: My Add-On for MAP (minimum advertised price).

lat9:

Line 300 of the as-distributed /admin/includes/modules/collect_info.php reads

  <label class="radio-inline"><?php echo zen_draw_radio_field('products_virtual', '0', ($pInfo->products_virtual == 0)) . TEXT_PRODUCT_NOT_VIRTUAL; ?></label>
> 
> 
> Noting that the definition TEXT_PRODUCTS_PRICE_EXCL isn't provided in v2.0.1, nor is it used.
> 
> 
> Where did your fresh install come from?

if we replace the (collect_info.php) from the plugin, then give us this error, also no way to input the item description. (see picture.). (if we using the original Collect_info.php from the ZC2.0.1 folder, it's working fine, But NO MAP.
Attachment 20629
29 May 2024, 2:59 PM
#118
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,717
Plugin Contributions:
56

Re: My Add-On for MAP (minimum advertised price).

You're right, @lat9. It looks as though both of those files are from Github on the master branch (i.e. unreleased version 2.1.0).

30 May 2024, 10:26 PM
#119
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: My Add-On for MAP (minimum advertised price).

Oops. My bad.
I've uploaded a new zip for the plugin, called it v2.0.1

7 Jun 2024, 4:35 PM
#120
dsc7050 avatar

dsc7050

New Zenner

Join Date:
Sep 2018
Location:
UUSA
Posts:
44
Plugin Contributions:
0

Re: My Add-On for MAP (minimum advertised price).

DrByte:

Oops. My bad.
I've uploaded a new zip for the plugin, called it v2.0.1

we have one more issue, after we install this new plugin, all products don't display the price, until we add the product to the shopping cart then we can see the price. (but the product doesn't enable the (M.A.P)).