Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter steffykristiensen

    (@steffykristiensen)

    Hi Krystian

    Thank you again for your support, the 29 character worked like a charm

    I will try to set up a staging site and test the sku version.. did not thought of using chatgpt for testing that

    thank you again, have a good day

    Steffy

    Thread Starter steffykristiensen

    (@steffykristiensen)

    Hi Krystian,

    thanks again for your help, on this one I don’t try to shorten the name but to replace it by the sku

    here is the code I have modified

    add_filter('ppcp_create_order_request_body_data', function (array $data): array {
        foreach ($data['purchase_units'] as $index => $purchase_unit) {
            // extract order number from custom_id
            $order_number = isset($purchase_unit['custom_id']) ? $purchase_unit['custom_id'] : 'N/A';
    
            foreach ($purchase_unit['items'] as $item_index => $item) {
                $data['purchase_units'][$index]['items'][$item_index]['name'] = $data['purchase_units'][$index]['items'][$item_index]['sku'];
            }
        }
        return $data;
    });
    
    add_filter('ppcp_patch_order_request_body_data', function (array $patches_array): array {
        foreach ($patches_array as $patch_index => $patch) {
            if (isset($patch['value']['items'])) {
                // extract order number from custom_id
                $order_number = isset($patch['value']['custom_id']) ? $patch['value']['custom_id'] : 'N/A';
    
                    unset($patches_array[$patch_index]['value']['items'][$item_index]['sku']);
                    $patches_array[$patch_index]['value']['items'][$item_index]['name'] = $patches_array[$patch_index]['value']['items'][$item_index]['sku'];
                }
            }
        }
        return $patches_array;
    });

    is it possible to have a sand box account used only for admin? my problem is the site is live, what would be the best for test purpose on paypal?

    thank you again

    Steffy

    Thread Starter steffykristiensen

    (@steffykristiensen)

    Hi Krystian

    Thank you very very much for your kind assistance…

    I will review your code to learn from it and see how it is different with what I came with..

    Thank you again

    what about the part to replace the name by the sku? is my adaptation of your code correct?

    thank you very much in advance

    Steffy

    Thread Starter steffykristiensen

    (@steffykristiensen)

    in the scenario I would rather change the title name by the sku, would the following work, I tried to adapt from here https://gist.github.com/InpsydeNiklas/bebf38d610dd3d928412c5ecde4925ee

    add_filter('ppcp_create_order_request_body_data', function (array $data): array {
        foreach ($data['purchase_units'] as $index => $purchase_unit) {
            // extract order number from custom_id
            $order_number = isset($purchase_unit['custom_id']) ? $purchase_unit['custom_id'] : 'N/A';
    
            foreach ($purchase_unit['items'] as $item_index => $item) {
                $data['purchase_units'][$index]['items'][$item_index]['name'] = $data['purchase_units'][$index]['items'][$item_index]['sku'];
            }
        }
        return $data;
    });
    
    add_filter('ppcp_patch_order_request_body_data', function (array $patches_array): array {
        foreach ($patches_array as $patch_index => $patch) {
            if (isset($patch['value']['items'])) {
                // extract order number from custom_id
                $order_number = isset($patch['value']['custom_id']) ? $patch['value']['custom_id'] : 'N/A';
    
                    unset($patches_array[$patch_index]['value']['items'][$item_index]['sku']);
                    $patches_array[$patch_index]['value']['items'][$item_index]['name'] = $patches_array[$patch_index]['value']['items'][$item_index]['sku'];
                }
            }
        }
        return $patches_array;
    });

    thank you in advance

    Thread Starter steffykristiensen

    (@steffykristiensen)

    if I want to limit to 29 caracters do you think the following will work?

    function max_title_length( $title, $max ) {
    if( strlen( $title ) > $max ) {
    return substr( $title, 0, $max ). ” …”;
    } else {
    return $title;
    }
    }

    add_filter(‘wc_ppcp_get_order_item’, function($item, $order_item){
    $item->setName($order_item->max_title_length(get_name(),29));
    return $item;
    }, 10, 2);

    thank you in advance

    Thread Starter steffykristiensen

    (@steffykristiensen)

    I also have a probleme on the product detail page on the admin side
    it shows the photo background of the page and has not the grey background while it is present on the front page

    Thread Starter steffykristiensen

    (@steffykristiensen)

    ps: light grey not really white indeed

Viewing 7 replies - 1 through 7 (of 7 total)