mweimerskirch / wordpress-qtranslate-support-for-woocommerce

Plugin to make qTranslate work with WooCommerce
wordpress.org/plugins/qtranslate-support-for-woocommerce/
MIT License
6 stars 7 forks source link

Small fix for paypal #13

Closed deweydb closed 10 years ago

deweydb commented 10 years ago

(sorry i should create a pull request i guess but i don't know how)

function waspdigital_woocommerce_paypal_qtranslate_product_name($paypal_args){
    // woocommerce uses a function 'paypal_item_name' which shortens these descriptions and seems to crop off part of qtranslates string
    // an example would be like this:
    // [item_name_1] => <!--:en-->Software Development, Methodology and Tools<!--:-->
    // which appears to be missing other languages
    // this patch just strips out the extra qtranslate stuff so that it doesn't look horrible at paypal checkout.
    $lang = qtrans_getLanguage();
    foreach($paypal_args as $key=>$value){
        if(strpos($key, 'item_name_') !== false){
            $paypal_args[$key] = str_replace('<!--:'.$lang.'-->', '', str_replace('<!--:-->', '', $paypal_args[$key]));
        }
    }
    return $paypal_args;
}
add_filter( 'woocommerce_paypal_args', 'waspdigital_woocommerce_paypal_qtranslate_product_name' );
mweimerskirch commented 10 years ago

You can click on the file and then on the "edit" button above the file. This will guide you through the steps to create a pull request. This way your name will appear in the commit log. However, it isn't really clear to me where this problem appears. Could you attach a screenshot or a more detailed description?

deweydb commented 10 years ago

Before my patch: screen shot 2014-07-02 at 3 14 24 pm

After my patch: screen shot 2014-07-02 at 3 15 03 pm

deweydb commented 10 years ago

I fixed my source code a little bit. it was hacky before, i didn't realize qtranslate had a function for what i was trying to do.