• Resolved eyahyakhan

    (@eyahyakhan)


    I want to call the function of attributeInfo()in functions.php from products-sttribtes.php.
    see the code in both file that I did. It works for simple product but not work in variable product. It makes error. Little bit description: I created a page in dashboard name ‘lagerstatus-attr-info’ as private. In frontend there will be a info icon(info_24_24.png in functions.php) and when I click on info icon then lagerstatus-attr-info page will display as popup window with lightbox.
    Can anyone solve it or give me some idea how can I solve it. if need more description you can ask me.

    functions.php

    include ‘woocommerce’.’/’.’single-product’.’/’.’product-attributes.php’;
    add_filter(‘woocommerce_get_availability’, ‘wcs_custom_get_availability’, 1, 2);
    function wcs_custom_get_availability($availability, $product) {
    $stockstatus = ‘<div class=”attribute-pair”>’
    .'<span class=”attr-name”>Stockstatus’
    .'< ahref=”#lagerstatus-popup”>’
    .'</aa>’
    .'<div id=”lagerstatus-popup” class=”lightbox-by-id lightbox-content mfp-hide lightbox-white ” style=”max-width:650px ;padding:20px”>’
    .attributeInfo(‘lagerstatus’)
    .'</div>’
    .'</span>’
    .'</div>’;
    }

    product-attributes.php

    $GLOBALS[‘attrInfoFileEnding’] = ‘-attr-info’;
    $attGroups = getAttributeGroupNames();
    $dbAttrs = collectDbAttributes($attributes, $product);
    $pageAttrs = getPageAttributes();
    $pageAttrs = copyToPageAttributes($dbAttrs, $pageAttrs);
    $pageAttrs = removeAttributesWithoutValue($pageAttrs);
    renderPage($pageAttrs, $attGroups);

    function attributeInfo($attributeName){
    $wpPageTitle = “”;
    $pageContent = “”;

    // Find page through title
    $wpPageTitle = $attributeName . $GLOBALS[‘attrInfoFileEnding’];

    if (get_page_by_title($wpPageTitle)) {
    $attrInfoPage = get_page_by_title($wpPageTitle);
    $pageContent .= $attrInfoPage->post_content;
    }else{
    echo “<br>FILE ” . $wpPageTitle . ” NOT FOUND”;
    }

    $pageContent .= ‘<button id=”btn-stel-pop-close”title=”Close (Esc)” type=”button” class=”mfp-close”>×</button>’;
    return $pageContent;
    }

    • This topic was modified 4 years ago by eyahyakhan.
    • This topic was modified 4 years ago by eyahyakhan.
    • This topic was modified 4 years ago by James Huff.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘call page and display as popup window’ is closed to new replies.