Plugin Directory

Changeset 2820025


Ignore:
Timestamp:
11/17/2022 07:17:22 PM (3 years ago)
Author:
heimanj
Message:

Updating to 1.9.0 (Adding "swmulticart" and "swmulticheckout")

Location:
swidget-for-cmp
Files:
10 added
3 edited

Legend:

Unmodified
Added
Removed
  • swidget-for-cmp/trunk/readme.txt

    r2775742 r2820025  
    55Requires at least: 4.1.0 
    66Tested up to: 5.8.1 
    7 Stable tag: 1.8 
     7Stable tag: 1.9 
    88Requires PHP: 5.2 
    99License: GPLv2 or later 
     
    1717
    1818#### Add to Cart
    19 
    2019`[swaddtocart site="siteID" item="itemID"]`   
    2120
     
    4241Optional parameter `date="YYYYMMDD"` should only be used for timed items. 
    4342_Note: timed items use the item ID of the timeslot, NOT the group ID._
     43
     44#### Multi-Item Add to Cart
     45`[swmulticart site="siteID" items="itemsString"]` 
     46_Desplays a series of items as a drop-down menu.  "items" expects a comma-delimited list of Siriusware item IDs._
     47
     48#### Multi-Item Quick Checkout 
     49`[swmulticheckout items="itemsString"]` 
     50Optional parameter `site="siteID"` 
     51_Desplays a series of items as a drop-down menu.  "items" expects a comma-delimited list of Siriusware item IDs._
    4452
    4553#### Cart
     
    93101* **Select New Date** (`sw_txt_select_new_date`) - The label text for the date selector (timed ticketing)
    94102* **Select New Time** (`sw_txt_select_new_time`) - The label text for the time selector (timed ticketing)
     103* **Select New Item** (`sw_txt_select_new_item`) - The label text for the item selector (multi-item)
    95104* **Date Dropdown Placeholder** (`sw_txt_date_dropdown_placeholder`) - The default text for the date selector (timed ticketing)
    96105* **Time Dropdown Placeholder** (`sw_txt_time_dropdown_placeholder`) - The default text for the time selector (timed ticketing)
     106* **Item Dropdown Placeholder** (`sw_txt_item_dropdown_placeholder`) - The default text for the item selector (multi-item)
    97107* **Pay What you Wish Placeholder** (`sw_txt_pay_what_you_wish`) - The default text for the pay what you wish message
    98108
     
    167177== Changelog ==
    168178
     179= 1.9.0 =
     180
     181* Added "swmulticart" and "swmulticheckout" shortcodes
     182
    169183= 1.8.1 =
    170184
  • swidget-for-cmp/trunk/settingsPage.php

    r2775742 r2820025  
    4747    "sw_txt_select_new_date" => "Select a different date",
    4848    "sw_txt_select_new_time" => "Select a different time",
     49    "sw_txt_select_new_item" => "Select a different item",
    4950    "sw_txt_date_dropdown_placeholder" => "Select a date",
    5051    "sw_txt_time_dropdown_placeholder" => "Select a time",
     52    "sw_txt_item_dropdown_placeholder" => "Select an item",
    5153  );
    5254}
  • swidget-for-cmp/trunk/swidget-cmp.php

    r2775796 r2820025  
    55GitHub Plugin URI: CMP-Studio/swidget-cmp
    66Description: Siriusware Widget for Carnegie Museusms of Pittsburgh
    7 Version: 1.8.1
     7Version: 1.9.0
    88Author: Carnegie Museums of Pittsburgh
    99Author URI: http://www.carnegiemuseums.org
     
    1515
    1616//Session handling via DB
    17 //see https://pippinsplugins.com/storing-session-data-in-wordpress-without-_session/
     17//see https://pippinsplugins.com/storing-session-data-in-wordpress-without-session/
    1818if (!class_exists("EDD_Session")) {
    1919    include_once dirname( __FILE__ ) . '/edd/class-edd-session.php';
     
    4646}
    4747
    48 //Initialize
     48/*
     49 * Initialize
     50 */
    4951if(!function_exists('swcmp_shortcodes_init')){
    5052  function swcmp_session_init()
     
    125127    "sw_txt_select_new_date" => "txtSelectNewDate",
    126128    "sw_txt_select_new_time" => "txtSelectNewTime",
     129    "sw_txt_select_new_item" => "txtSelectNewItem",
    127130    "sw_txt_date_dropdown_placeholder" => "txtDateDropdownPlaceholder",
    128131    "sw_txt_time_dropdown_placeholder" => "txtTimeDropdownPlaceholder",
     132    "sw_txt_item_dropdown_placeholder" => "txtItemDropdownPlaceholder",
    129133    "sw_pre_selected_date" => "preSelectedDate",
    130134    "sw_pre_selected_time" => "preSelectedTime",
     
    154158}
    155159
    156 //The checkout widget
     160/*
     161 * The checkout ("quick") widgets
     162 */
    157163function swcmp_init_checkout()
    158164{
     
    200206    $group = intval($co_atts["group"]);
    201207    $settings = swcmp_get_settings($atts);
     208   
    202209    $class = "swcmp_{$site}_{$group}";
    203 
    204210    $out = <<<EOT
    205211    <script>
     
    254260  }
    255261
     262  function swcmp_multi_checkout($atts=[], $content=null, $tag='') {
     263  }
     264
     265  function swcmp_multiselect_quick($atts=[], $content=null, $tag='')
     266  {
     267    // normalize attribute keys, lowercase
     268    $atts = array_change_key_case((array)$atts, CASE_LOWER);
     269    $co_atts = shortcode_atts([
     270      "site" => null,
     271      "items" => null
     272    ], $atts, $tag);
     273    //Start Output
     274    $site = intval($co_atts["site"]);
     275    $items = $co_atts["items"];
     276    //sanitize $items as comma-delimited integers.  If it fails, just fall back to the int value
     277    $validMatch = preg_match('/^(\d+,?)+$/', $items);
     278    if (!$validMatch) {
     279        $items = intval($co_atts["items"]);
     280    }
     281    $settings = swcmp_get_settings($atts);
     282    //I don't think date will be used...
     283
     284    //since we don't have a traditional site & item...
     285    $itemsStr = str_replace(",", "", $items);
     286    $class = ($site ? "swcmp_{$site}_{$itemsStr}" : "swcmp_{$itemsStr}");
     287    $out = <<<EOT
     288    <script>
     289    jQuery(document).ready(function() {
     290      jQuery("#swidget-script").one('load swidgetLoaded', function() {
     291        jQuery(".$class").swMultiSelectorQuick($site, "$items", $settings);
     292      });
     293      if (jQuery.fn.swMultiSelectorQuick) {
     294        jQuery("#swidget-script").trigger('swidgetLoaded');
     295      }
     296    });
     297    </script>
     298    <div class="swidget-holder $class"></div>
     299EOT;
     300
     301    return $out;
     302  }
     303
    256304  add_shortcode('swcheckout', __NAMESPACE__ . '\swcmp_checkout');
    257305  add_shortcode('swcheckouttimed', __NAMESPACE__ . '\swcmp_checkouttimed');
    258306  add_shortcode('swoneclickcheckout', __NAMESPACE__ . '\swcmp_1clickcheckout');
    259 }
    260 
    261 
    262 //Cart based functions
     307  //add_shortcode('swmulticheckout', __NAMESPACE__ . '\swcmp_multi_checkout');  //calls multiple quickCheckout instances
     308  add_shortcode('swmulticheckout', __NAMESPACE__ . '\swcmp_multiselect_quick');
     309}
     310
     311
     312/*
     313 * The cart based widgets
     314 */
    263315function swcmp_init_cart()
    264316{
     
    276328
    277329    $class = "swcmp_cart_$cart";
    278 
    279330    $out = <<<EOT
    280331    <script>
     
    311362
    312363    $class = "swcmp_$site" . "_" . $item;
    313 
    314364    $out = <<<EOT
    315365    <script>
     
    346396
    347397    $class = "swidget_$site" . "_" . $group;
    348 
    349398    $out = <<<EOT
    350399    <script>
     
    475524  }
    476525
     526  function swcmp_multi_addtocart($atts=[], $content=null, $tag='')
     527  {
     528    // normalize attribute keys, lowercase
     529    $atts = array_change_key_case((array)$atts, CASE_LOWER);
     530    $co_atts = shortcode_atts([
     531      "site" => null,
     532      "items" => null,
     533      "date" => null
     534    ], $atts, $tag);
     535    //Start Output
     536    $site = intval($co_atts["site"]);
     537    $items = $co_atts["items"];
     538    //sanitize $items as comma-delimited integers.  If it fails, just fall back to the int value
     539    $validMatch = preg_match('/^(\d+,?)+$/', $items);
     540    if (!$validMatch) {
     541        $items = intval($co_atts["items"]);
     542    }
     543    $date = ($co_atts["date"] ? intval($co_atts["date"]) : "null");
     544    $settings = swcmp_get_settings($atts);
     545   
     546    $cart = swcmp_get_cart($site);
     547    if(!isset($cart)) return "";
     548
     549    $class = "swcmp_$site" . "_" . $item;
     550    $out = <<<EOT
     551    <script>
     552    jQuery( document ).ready(function(){
     553      jQuery("#swidget-script").one('load swidgetLoaded', function() {
     554        jQuery(".$class").swMultiCart($cart, $site, $settings);
     555      });
     556      if (jQuery.fn.swMultiCart) {
     557        jQuery("#swidget-script").trigger('swidgetLoaded');
     558      }
     559    });
     560    </script>
     561    <div class="swidget-holder $class" data-items="$items" data-start_date="$date"></div>
     562EOT;
     563
     564    return $out;
     565  }
     566
     567  function swcmp_multiselect_cart($atts=[], $content=null, $tag='')
     568  {
     569    // normalize attribute keys, lowercase
     570    $atts = array_change_key_case((array)$atts, CASE_LOWER);
     571    $co_atts = shortcode_atts([
     572      "site" => null,
     573      "items" => null,
     574    ], $atts, $tag);
     575    //Start Output
     576    $site = intval($co_atts["site"]);
     577    $items = $co_atts["items"];
     578    //sanitize $items as comma-delimited integers.  If it fails, just fall back to the int value
     579    $validMatch = preg_match('/^(\d+,?)+$/', $items);
     580    if (!$validMatch) {
     581        $items = intval($co_atts["items"]);
     582    }
     583    $settings = swcmp_get_settings($atts);
     584
     585    $cart = swcmp_get_cart($site);
     586    if(!isset($cart)) return "<p>Failed</p>";
     587
     588    $itemsStr = str_replace(",", "", $items);
     589    $class = "swcmp_{$site}_{$itemsStr}";
     590    $out = <<<EOT
     591    <script>
     592    jQuery(document).ready(function() {
     593      jQuery("#swidget-script").one('load swidgetLoaded', function() {
     594        jQuery(".$class").swMultiSelectorCart($cart, $site, "$items", $settings);
     595      });
     596      if (jQuery.fn.swMultiSelectorCart) {
     597        jQuery("#swidget-script").trigger('swidgetLoaded');
     598      }
     599    });
     600    </script>
     601    <div class="swidget-holder $class"></div>
     602EOT;
     603
     604    return $out;
     605  }
     606
    477607  function swcmp_getcardbalance()
    478608  {
     
    501631  add_shortcode('swaddtocarttimed_firstga', __NAMESPACE__ . '\swcmp_addtocarttimed_firstga');
    502632  add_shortcode('swoneclickaddtocart', __NAMESPACE__ . '\swcmp_1clickaddtocart');
     633  //add_shortcode('swmulticart', __NAMESPACE__ . '\swcmp_multi_addtocart');
     634  add_shortcode('swmulticart', __NAMESPACE__ . '\swcmp_multiselect_cart');
    503635  add_shortcode('swcardbalance', __NAMESPACE__ . '\swcmp_getcardbalance');
    504636}
Note: See TracChangeset for help on using the changeset viewer.