Plugin Directory

Changeset 3200980


Ignore:
Timestamp:
12/02/2024 02:23:41 PM (16 months ago)
Author:
bc2018
Message:

update compability

Location:
bc-woo-custom-thank-you-pages/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • bc-woo-custom-thank-you-pages/trunk/Initiator.php

    r3180039 r3200980  
    55 * Plugin URI: https://www.binarycarpenter.com/app/bc-thank-you-page-builder-for-woocommerce/
    66 * Description: Helps you create custom thank you pages for products, categories
    7  * Version: 1.4.19
     7 * Version: 1.4.20
    88 * Author: WooCommerce & WordPress Tutorials
    99 * Author URI: https://www.binarycarpenter.com
    1010 * License: GPL2
    1111 * Text Domain: bc-custom-thank-you
    12  * Tested up to: 6.6.2.
     12 * Tested up to: 6.7.1.
    1313 * WC requires at least: 3.0.0
    14  * WC tested up to: 9.3.3
     14 * WC tested up to: 9.4.2
    1515 */
    1616
     
    119119        try {
    120120            $body = json_decode(wp_remote_retrieve_body($response));
    121             error_log("body is " . print_r($body, true));
    122121            if (!isset($body->versionNumber)) {
    123122                error_log("error checking for new version for wp thank you page builder");
     
    215214            $products = $order->get_items();
    216215
    217             $first_product = null;
    218             //get the first product in cart to get its thank you page
    219             foreach ($products as $product) {
    220                 $first_product = $product->get_data();
     216            $first_product_id = 0;
     217            $first_product_variation_id = 0;
     218
     219            foreach ($products as $item_id => $item) {
     220                // Product name
     221                $product_name = $item->get_name();
     222
     223                // Product ID
     224                if (method_exists($item, 'get_product_id')) {
     225                    error_log("setting first product id to " . $item->get_product_id());
     226                    $first_product_id = $item->get_product_id();
     227                }
     228
     229                // Variation ID (if applicable)
     230                if (method_exists($item, 'get_variation_id')) {
     231                    error_log("setting first variation id to " . $item->get_variation_id());
     232                    $first_product_variation_id = $item->get_variation_id();
     233                }
     234
     235                //log all the info
     236                error_log("first product name: " . $product_name);
     237                error_log("first product id: " . $first_product_id);
     238                error_log("first variation id: " . $first_product_variation_id);
     239                //only get the first product
    221240                break;
    222241            }
    223             $first_product_id = $first_product['product_id'];
    224242
    225243
     
    230248
    231249            $product_thank_you_pages = $option->get_array(Oname::PER_PRODUCT_THANK_YOU_PAGE);
     250            $product_variation_thank_you_pages = $option->get_array(Oname::PER_PRODUCT_VARIATION_THANK_YOU_PAGE);
    232251            $category_thank_you_pages = $option->get_array(Oname::PER_CATEGORY_THANK_YOU_PAGE);
    233252
     
    237256            $product_cats_ids = $first_product->get_category_ids();
    238257
    239             //if the product has a specific thank you page set for it, then take that thank you page
    240             if (isset($product_thank_you_pages["$first_product_id"])) {
     258            //inspect the selected product
     259            error_log("product id " . $first_product_id);
     260
     261            if (isset($product_variation_thank_you_pages["$first_product_variation_id"])) {
     262                error_log("setting thank you page id to product variation " . $product_variation_thank_you_pages["$first_product_variation_id"]);
     263                $thank_you_page_id = $product_variation_thank_you_pages["$first_product_variation_id"];
     264            } else if (isset($product_thank_you_pages["$first_product_id"])) {
     265                error_log("setting thank you page id to product " . $product_thank_you_pages["$first_product_id"]);
    241266                $thank_you_page_id = $product_thank_you_pages["$first_product_id"];
    242267            } else {
     
    428453                $products_select = array();
    429454
     455                $variations_select = array();
     456
    430457                foreach ($products as $product) {
     458
     459                    //if the product has variable, add it to the list
     460                    if ($product->is_type('variable')) {
     461                        $children   = $product->get_children($args = '', $output = OBJECT);
     462                        foreach ($children as $key => $value) {
     463                            $product_variatons = new \WC_Product_Variation($value);
     464                            if ($product_variatons->exists() && $product_variatons->variation_is_visible()) {
     465                                $variations[$value] = $product_variatons->get_variation_attributes();
     466                                $variations_select[$value] = $product_variatons->get_name();
     467                            }
     468                        }
     469                    }
    431470
    432471                    $products_select[$product->get_id()] = $product->get_name();
     
    448487                        $option_form->key_select_select(Oname::PER_PRODUCT_THANK_YOU_PAGE, $products_select, $pages_select, 'Pick product', 'Pick thank you page', !Config::IS_PRO)
    449488                    ), false);
     489
     490                $thank_you_tab[] =
     491                    $option_form->card_section('Specify thank you page per product variation', array(
     492                        $option_form->key_select_select(Oname::PER_PRODUCT_VARIATION_THANK_YOU_PAGE, $variations_select, $pages_select, 'Pick product', 'Pick thank you page', !Config::IS_PRO)
     493                    ), false);
     494
     495
    450496                //activation section
    451497                if (!Config::IS_PRO) {
  • bc-woo-custom-thank-you-pages/trunk/inc/Config.php

    r3180039 r3200980  
    2121    const KEY_CHECK_OPTION = 'bc_woo_custom_tk_check_option_key';
    2222    const LICENSE_KEY_OPTION = 'bc_woo_custom_tk_stored_license_key';
    23     const PLUGIN_VERSION_NUMBER = 115;
     23    const PLUGIN_VERSION_NUMBER = 116;
    2424    const OPTION_NAME = 'bc_menu_bar_cart_option_name';
    2525    const IS_PRO = false;
  • bc-woo-custom-thank-you-pages/trunk/inc/Options_Name.php

    r3005287 r3200980  
    1010    const PER_CATEGORY_THANK_YOU_PAGE = 'thank_you_page_per_category';
    1111    const PER_PRODUCT_THANK_YOU_PAGE = 'thank_you_page_per_product';
     12    const PER_PRODUCT_VARIATION_THANK_YOU_PAGE = 'thank_you_page_per_product_variation';
    1213    const SHOP_PAGE = 'shop_page';
    1314    const CUSTOM_PAGES_PER_CATEGORY = 'custom_pages_per_category'; //setting the display page per category
  • bc-woo-custom-thank-you-pages/trunk/readme.txt

    r3180039 r3200980  
    77WC tested up to: 9.0.2
    88Requires PHP: 5.3
    9 Stable tag: 1.4.19
     9Stable tag: 1.4.20
    1010
    1111Create thank you pages for all products, per products or per category
Note: See TracChangeset for help on using the changeset viewer.