Plugin Directory

Changeset 3184360


Ignore:
Timestamp:
11/08/2024 11:14:46 AM (17 months ago)
Author:
hertwill
Message:

Update to version 1.1.0 from GitHub

Location:
hertwill
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • hertwill/tags/1.1.0/hertwill.php

    r3170745 r3184360  
    44 * Plugin URI: https://hertwill.com/
    55 * Description: Hertwill companion plugin for managing your products
    6  * Version: 1.0.6
     6 * Version: 1.1.0
    77 * Author: Hertwill
    88 * Author URI: https://hertwill.com
  • hertwill/tags/1.1.0/options.php

    r3036277 r3184360  
    6464        global $post;
    6565
    66         // Check if 'hw' metadata exists for the product
    67         $hw_metadata = get_post_meta($post->ID, '_hw_product_cost', true);
     66        $product = wc_get_product($post->ID);
    6867
    69         // Check if 'cost_price' field exists within 'hw' metadata
    70         $cost_price_value = isset($hw_metadata) ? $hw_metadata : '';
     68        // Handle simple product
     69        if ($product->is_type('simple')) {
     70            $cost_price_value = get_post_meta($post->ID, '_hw_product_cost', true);
    7171
    72         // Display cost price field only if 'cost_price' exists in 'hw' metadata
    73         if (!empty($cost_price_value)) {
    74             woocommerce_wp_text_input(array(
    75                 'id'                 => 'hw_cost_price',
    76                 'class'              => 'short wc_input_price',
    77                 'label'              => 'Cost (€)',
    78                 'data_type'          => 'price',
    79                 'value'              => $cost_price_value,
    80                 'custom_attributes'  => array(
    81                     'readonly' => 'readonly',
    82                 ),
    83             ));
     72            if (!empty($cost_price_value)) {
     73                woocommerce_wp_text_input(array(
     74                    'id'                 => 'hw_cost_price',
     75                    'class'              => 'short wc_input_price',
     76                    'label'              => 'Cost (€)',
     77                    'data_type'          => 'price',
     78                    'value'              => $cost_price_value,
     79                    'custom_attributes'  => array(
     80                        'readonly' => 'readonly',
     81                    ),
     82                ));
     83            }
    8484        }
     85
     86        // Handle variable product
     87        if ($product->is_type('variable')) {
     88
     89            $variations = $product->get_children();
     90            foreach ($variations as $variation_id) {
     91                $variation_product = wc_get_product($variation_id);
     92
     93                $variation_cost_price = get_post_meta($variation_id, '_hw_product_cost', true);
     94                $variation_cost_price = !empty($variation_cost_price) ? $variation_cost_price : '';
     95
     96                $variation_sku = $variation_product->get_sku();
     97
     98                if (!empty($variation_cost_price)) {
     99                    woocommerce_wp_text_input(array(
     100                        'id'                 => 'hw_cost_price_' . $variation_id,
     101                        'class'              => 'short wc_input_price',
     102                        'label'              => 'Cost (€) for SKU ' . $variation_sku,
     103                        'data_type'          => 'price',
     104                        'value'              => $variation_cost_price,
     105                        'custom_attributes'  => array(
     106                            'readonly' => 'readonly',
     107                        ),
     108                    ));
     109                }
     110            }
     111        }
     112
    85113    }
    86114
  • hertwill/tags/1.1.0/readme.txt

    r3170745 r3184360  
    44Tags: ecommerce, woocommerce, dropshipping, fulfillment
    55Requires at least: 6.3
    6 Tested up to: 6.6
     6Tested up to: 6.7
    77Requires PHP: 7.4
    8 Stable tag: 1.0.6
     8Stable tag: 1.1.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7171
    7272- Initial release
     73
     74= 1.1.0 =
     75
     76- Display product cost for variable products
  • hertwill/trunk/hertwill.php

    r3170745 r3184360  
    44 * Plugin URI: https://hertwill.com/
    55 * Description: Hertwill companion plugin for managing your products
    6  * Version: 1.0.6
     6 * Version: 1.1.0
    77 * Author: Hertwill
    88 * Author URI: https://hertwill.com
  • hertwill/trunk/options.php

    r3036277 r3184360  
    6464        global $post;
    6565
    66         // Check if 'hw' metadata exists for the product
    67         $hw_metadata = get_post_meta($post->ID, '_hw_product_cost', true);
     66        $product = wc_get_product($post->ID);
    6867
    69         // Check if 'cost_price' field exists within 'hw' metadata
    70         $cost_price_value = isset($hw_metadata) ? $hw_metadata : '';
     68        // Handle simple product
     69        if ($product->is_type('simple')) {
     70            $cost_price_value = get_post_meta($post->ID, '_hw_product_cost', true);
    7171
    72         // Display cost price field only if 'cost_price' exists in 'hw' metadata
    73         if (!empty($cost_price_value)) {
    74             woocommerce_wp_text_input(array(
    75                 'id'                 => 'hw_cost_price',
    76                 'class'              => 'short wc_input_price',
    77                 'label'              => 'Cost (€)',
    78                 'data_type'          => 'price',
    79                 'value'              => $cost_price_value,
    80                 'custom_attributes'  => array(
    81                     'readonly' => 'readonly',
    82                 ),
    83             ));
     72            if (!empty($cost_price_value)) {
     73                woocommerce_wp_text_input(array(
     74                    'id'                 => 'hw_cost_price',
     75                    'class'              => 'short wc_input_price',
     76                    'label'              => 'Cost (€)',
     77                    'data_type'          => 'price',
     78                    'value'              => $cost_price_value,
     79                    'custom_attributes'  => array(
     80                        'readonly' => 'readonly',
     81                    ),
     82                ));
     83            }
    8484        }
     85
     86        // Handle variable product
     87        if ($product->is_type('variable')) {
     88
     89            $variations = $product->get_children();
     90            foreach ($variations as $variation_id) {
     91                $variation_product = wc_get_product($variation_id);
     92
     93                $variation_cost_price = get_post_meta($variation_id, '_hw_product_cost', true);
     94                $variation_cost_price = !empty($variation_cost_price) ? $variation_cost_price : '';
     95
     96                $variation_sku = $variation_product->get_sku();
     97
     98                if (!empty($variation_cost_price)) {
     99                    woocommerce_wp_text_input(array(
     100                        'id'                 => 'hw_cost_price_' . $variation_id,
     101                        'class'              => 'short wc_input_price',
     102                        'label'              => 'Cost (€) for SKU ' . $variation_sku,
     103                        'data_type'          => 'price',
     104                        'value'              => $variation_cost_price,
     105                        'custom_attributes'  => array(
     106                            'readonly' => 'readonly',
     107                        ),
     108                    ));
     109                }
     110            }
     111        }
     112
    85113    }
    86114
  • hertwill/trunk/readme.txt

    r3170745 r3184360  
    44Tags: ecommerce, woocommerce, dropshipping, fulfillment
    55Requires at least: 6.3
    6 Tested up to: 6.6
     6Tested up to: 6.7
    77Requires PHP: 7.4
    8 Stable tag: 1.0.6
     8Stable tag: 1.1.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7171
    7272- Initial release
     73
     74= 1.1.0 =
     75
     76- Display product cost for variable products
Note: See TracChangeset for help on using the changeset viewer.