Plugin Directory

Changeset 3336133


Ignore:
Timestamp:
07/29/2025 04:53:44 PM (8 months ago)
Author:
printess
Message:
  • Added option to use ACF field names instead of labels while assigning form field values
  • Fixed variant option to use given template name as merge template for variants where not all variants use the template name as merge template
Location:
printess-editor/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • printess-editor/trunk/includes/js/printessWoocommerce.js

    r3336068 r3336133  
    942942        const currentProductOptions = getCurrentProductOptionValues(settings.product);
    943943        const currentVariant = getCurrentVariant(currentProductOptions, settings.product);
    944         if (currentVariant && currentVariant.templateName && !currentVariant.templateIsMergeTemplate) {
    945             context.templateNameOrSaveToken = currentVariant.templateName;
     944        if (currentVariant && currentVariant.templateName) {
     945            context.templateNameOrSaveToken = currentVariant.templateIsMergeTemplate ? settings.product.templateName : currentVariant.templateName;
    946946        }
    947947        //parse url settings and apply these
     
    10361036        const selectedVariant = getCurrentVariant(getCurrentProductOptionValues(product), product);
    10371037        const variantsHaveTemplateNames = product.variants && typeof product.variants.find((x) => x.templateName && !x.templateIsMergeTemplate) !== "undefined" ? true : false;
    1038         if (selectedVariant != null && selectedVariant.templateName && !selectedVariant.templateIsMergeTemplate) {
    1039             templateName = selectedVariant.templateName;
     1038        if (selectedVariant != null && selectedVariant.templateName) {
     1039            templateName = selectedVariant.templateIsMergeTemplate ? product.templateName : selectedVariant.templateName;
    10401040        }
    10411041        if (!templateName && !variantsHaveTemplateNames) {
  • printess-editor/trunk/includes/printess-admin-settings.php

    r3332749 r3336133  
    230230    static function get_disable_basket_warning_on_unpersonalized_items() {
    231231        $setting = get_option( 'printess_disable_basket_warning_on_unpersonalized_items', false );
     232
     233        if ( 'on' === $setting ) {
     234            return true;
     235        }
     236
     237        return false;
     238    }
     239
     240    /**
     241     * Returns true in case the form field values pulled in from ACF plugin should use the acf field name instead of its label
     242    */
     243    static function get_use_acf_name_instead_of_label() {
     244        $setting = get_option( 'printess_use_acf_name_instead_of_label', false );
    232245
    233246        if ( 'on' === $setting ) {
     
    10721085        );
    10731086
     1087        register_setting(
     1088            'printess-settings',
     1089            'printess_use_acf_name_instead_of_label',
     1090            array(
     1091                'type'    => 'boolean',
     1092                'default' => false,
     1093            )
     1094        );
     1095
     1096        add_settings_field(
     1097            'printess_use_acf_name_instead_of_label',
     1098            __( 'Use names instead of labels for ACF fields', 'printess-editor' ),
     1099            function() {
     1100                $setting = get_option( 'printess_use_acf_name_instead_of_label', false );
     1101                $checked = '';
     1102
     1103                if ( null === $setting || empty( $setting ) ) {
     1104                    $setting = false;
     1105                }
     1106
     1107                if ( 'on' === $setting ) {
     1108                    $checked = 'checked';
     1109                }
     1110
     1111                ?>
     1112
     1113                <input type="checkbox" name="printess_use_acf_name_instead_of_label" <?php echo esc_html( $checked ); ?> >
     1114                <?php
     1115            },
     1116            'printess-settings',
     1117            'printess_settings_section'
     1118        );
     1119
    10741120        add_menu_page(
    10751121            'Printess',
  • printess-editor/trunk/printess.php

    r3336068 r3336133  
    55 * Plugin URI: https://printess.com/kb/integrations/woo-commerce/index.html
    66 * Developer: Bastian Kröger (support@printess.com); Alexander Oser (support@printess.com)
    7  * Version: 1.6.53
     7 * Version: 1.6.54
    88 * Author: Printess
    99 * Author URI: https://printess.com
     
    1414 * Tested up to: 6.8
    1515 *
    16  * Woo: 10000:924012dfsfhsf8429842386wdff234sfd
     16 * Woo: 10000:924013dfsfhsf8429842386wdff234sfd
    1717 * WC requires at least: 5.8
    1818 * WC tested up to: 9.8.2
     
    362362        if(in_array("all", $filter_lookup) || in_array("description", $filter_lookup))$form_fields["Description"] = get_user_meta($user_id, 'description', true);
    363363
    364 
    365 
    366 
    367364        if(in_array("all", $filter_lookup) || in_array("billingfirstname", $filter_lookup))$form_fields["BillingFirstname"] = $customer->billing["first_name"];
    368365        if(in_array("all", $filter_lookup) || in_array("billinglastname", $filter_lookup))$form_fields["BillingLastname"] = $customer->billing["last_name"];
     
    394391
    395392        if(null !== $acf_fields && false !== $acf_fields && is_array($acf_fields)) {
     393            $acf_label_property = PrintessAdminSettings::get_use_acf_name_instead_of_label() ? "name" : "label";
     394
    396395            foreach($acf_fields as $key => &$field) {
    397                 if(is_array($field) && array_key_exists("label", $field) && array_key_exists("value", $field) && (in_array("all", $filter_lookup) || in_array(strtolower($field["label"]), $filter_lookup))) {
    398                     $form_fields[$field["label"]] = $field["value"];
     396                if(is_array($field) && array_key_exists($acf_label_property, $field) && array_key_exists("value", $field) && (in_array("all", $filter_lookup) || in_array(strtolower($field[$acf_label_property]), $filter_lookup))) {
     397                    $form_fields[$field[$acf_label_property]] = $field["value"];
    399398                }
    400399            }
  • printess-editor/trunk/readme.txt

    r3336068 r3336133  
    296296= 1.6.53 =
    297297- Added support for merge templates inside variants
     298
     299= 1.6.54 =
     300- Added option to use ACF field names instead of labels while assigning form field values
     301- Fixed variant option to use given template name as merge template for variants where not all variants use the template name as merge template
Note: See TracChangeset for help on using the changeset viewer.