• How to set a character limit to product title so the size of the product, picture etc match each other the same way.

    I would like my product title to present as (exp. Product name info..) if it is more than x characters.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello,
    Do you mean it should crop titles longer than X, or not allow them to be entered at all?

    Thread Starter tasosalkis

    (@tasosalkis)

    Crop titles longer than X while on category page.

    add_filter('jigoshop\find\product', function($product) {
        if(\Jigoshop\Frontend\Pages::isProductCategory()) {
           $product->setName(substr($product->getName(),0,X -1))
        }
        return $product;
    }, 10, 2);

    Where X is your desired length.

    Thread Starter tasosalkis

    (@tasosalkis)

    I get this error when i try to insert it in the theme php

    Parse error: syntax error, unexpected ‘}’ in /srv/disk1/2554176/www/alktas.co.nf/wp-content/themes/phosphor/functions.php on line 12

    and the same when i tried on jigoshop php

    Parse error: syntax error, unexpected ‘}’ in /srv/disk1/2554176/www/alktas.co.nf/wp-content/plugins/jigoshop-ecommerce/jigoshop.php on line 43

    Anything else except (X) value i should change ?

    Correction:
    add_filter(‘jigoshop\find\product’, function($product) {
    if(\Jigoshop\Frontend\Pages::isProductCategory()) {
    $product->setName(substr($product->getName(),0,X -1));
    }
    return $product;
    }, 10, 2);

    Thread Starter tasosalkis

    (@tasosalkis)

    I still get this error. Any idea?

    Fatal error: Uncaught Error: Undefined constant ‘‘jigoshop\find\product’’ in /srv/disk1/2554176/www/alktas.co.nf/wp-content/themes/phosphor/functions.php:11 Stack trace: #0 /srv/disk1/2554176/www/alktas.co.nf/wp-settings.php(426): include() #1 /srv/disk1/2554176/www/alktas.co.nf/wp-config.php(93): require_once(‘/srv/disk1/2554…’) #2 /srv/disk1/2554176/www/alktas.co.nf/wp-load.php(37): require_once(‘/srv/disk1/2554…’) #3 /srv/disk1/2554176/www/alktas.co.nf/wp-blog-header.php(13): require_once(‘/srv/disk1/2554…’) #4 /srv/disk1/2554176/www/alktas.co.nf/index.php(17): require(‘/srv/disk1/2554…’) #5 {main} thrown in /srv/disk1/2554176/www/alktas.co.nf/wp-content/themes/phosphor/functions.php on line 11

    Please contact us at [email protected], so that I can debug the issue.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to set a character limit to product title?’ is closed to new replies.