Forum Replies Created

Viewing 15 replies - 1 through 15 (of 22 total)
  • Thread Starter muttly

    (@muttly)

    sorry for the delay in responding, I was away for a few days.

    This did eventually work although once I deleted the old info I imported it again and it still wasn’t complete. I’ve ran it about 5 times in total but not deleting the existing data and eventually all the data is there.

    Thread Starter muttly

    (@muttly)

    Sorry I should have explained further to the above, I meant in terms of the page orientation I could not get it right to match up width and height as expected.

    I have adapted my code to get the image displaying correctly but I’m using pixels rather than mm and forcing it the way I need.

    Would you have an email address I can send my zipped php file to? I can also include a screen shot of the settings I’m using. Maybe I’m doing something wrong but if I am, I can’t see it.

    Thread Starter muttly

    (@muttly)

    Sorry for the delay.

    I am using 6.4.6. My settings within the PDf section are set to:
    Paper Size: Custom Paper Size
    Width: 216
    Height: 211
    Unit: mm
    Paper Orientation: Landscape

    DPI is set to 300, format is “Standard”

    I’ve exported a test file and when exported I get width 211mm and height 216mm. As part of this design I need to place an image of the same dimensions within the pdf output. No matter what way I set it I cannot get it to output correctly.

    Is there some sort of output I can provide to help with this issue?

    Thread Starter muttly

    (@muttly)

    Thank you for the help. I’ve since changed direction and I’m using the GFAPI to set it on order completion.

    Thread Starter muttly

    (@muttly)

    That is perfect, thank you very much for your help!!

    Thread Starter muttly

    (@muttly)

    This is the code I use to add the products to the cart….

    /**
    * Automatically adding the product to the cart.
    */

    add_action(‘template_redirect’, ‘pt_add_wallet_to_cart’);

    function pt_add_wallet_to_cart(){// $item_key, $product_id ) {

    $product_category_id = 508; // ticket category id
    $free_product_id = 37913; // Ticket Wallet Stock product id

    if( is_cart() || is_checkout() ) {
    //Remove all variations <–
    foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
    $p_id = $cart_item[‘product_id’];
    $v_id = $cart_item[‘variation_id’];
    if($p_id==$free_product_id){
    if ($cart_item[‘variation_id’] == $v_id) {
    //remove single product
    WC()->cart->remove_cart_item($cart_item_key);
    }
    }
    }
    //–> Remove all varations

    //Add variations <–
    foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item){ // Loop through all products
    $p_id = $cart_item[‘product_id’];
    $terms = get_the_terms( $p_id, ‘product_cat’ );
    $cat_found=false;
    foreach ( $terms as $term ) { // Loop through all categories
    $cat_id = $term->term_id;
    if($cat_id==$product_category_id){ // If find product_category_id then break out
    $cat_found=true;
    break;
    }
    }
    $quantity = $cart_item[‘quantity’]; // Get quantity of this item
    $pa_tbs = $cart_item[‘variation’][‘attribute_pa_top-bar-style’]; // Get top bar style

    $pa_c = $cart_item[‘variation’][‘attribute_pa_colour’]; // Get top bar colour
    $pa_c=str_replace(‘-nc’,”,$pa_c); // Remove -nc from colour attribute

    $pa_ht = $cart_item[‘variation’][‘attribute_pa_home-team’]; // Get home team
    $pa_w = $cart_item[‘variation’][‘attribute_pa_wallet’]; // Get wallet

    if($pa_tbs==”){
    $pa_tbs=’youre-going-to’;
    }
    if($pa_c==”){
    $pa_c=’white’;
    }

    $taxonomy = ‘pa_top-bar-style’; // Get name rather than slug
    $t = get_term_by(‘slug’, $pa_tbs, $taxonomy);
    $pa_tbs_fv = $t->name;

    $taxonomy = ‘pa_colour’; // Get name rather than slug
    $t = get_term_by(‘slug’, $pa_c, $taxonomy);
    $pa_c_fv = $t->name;

    $free_variation=array( // Create array of names of attributes
    ‘Top Bar Style’ => $pa_tbs_fv,
    ‘Colour’ => $pa_c_fv,
    );
    $vx=get_variation_id_from_attributes($free_product_id,$pa_tbs,$pa_c); // Retrieve variation id
    //echo ‘<br><br>cat_found: ‘.$cat_found.'<br>cat_id: ‘.$cat_id.'<br>p_id: ‘.$p_id.'<br>tbs: ‘.$pa_tbs.'<br>tbs_fv: ‘.$pa_tbs_fv.'<br>c: ‘.$pa_c.'<br>c_fv: ‘.$pa_c_fv.'<br>w: ‘.$pa_w.'<br>ht: ‘.$pa_ht.'<br>vx: ‘.$vx;
    if($pa_w == ‘included’){ // If wallet is ‘included’ add product to cart
    WC()->cart->add_to_cart($free_product_id, $quantity, $vx, $free_variation);
    }
    }
    //–> Add variations
    }
    }

    function get_variation_id_from_attributes( $product_id, $topbarstyle, $colour ) {

    $topbarstyle = strtolower($topbarstyle);
    $colour = strtolower($colour);

    $variation_id = find_matching_product_variation_id ( $product_id, array(
    ‘attribute_pa_top-bar-style’ => $topbarstyle,
    ‘attribute_pa_colour’ => $colour
    ));

    return $variation_id;
    }

    function find_matching_product_variation_id($product_id, $attributes){
    return (new \WC_Product_Data_Store_CPT())->find_matching_product_variation(
    new \WC_Product($product_id),
    $attributes
    );
    }

    Thread Starter muttly

    (@muttly)

    I’m doing it via code. I am however using these 2 code snippets to hide them from the cart, cart count and emails. The customer doesn’t know about the product. I can include my code for adding the items if you want. But ideally just not including a hidden product would work well. It’s the only hidden product I have on the site and it’s use is solely for stock keeping.

    https://businessbloomer.com/woocommerce-hide-hidden-products-cart-order-emails/

    https://businessbloomer.com/woocommerce-exclude-hidden-products-from-mini-cart-counter/

    Thread Starter muttly

    (@muttly)

    Thank you, I will take a look. Where should I be putting that code?

    Thread Starter muttly

    (@muttly)

    Thank you! Thank you! Thank you!!

    It was the CSS. I removed the section above and it was displaying the fonts correctly. its taken another 30 minutes to get the logo right but its done now. Thank you so much!!

    Thread Starter muttly

    (@muttly)

    I cleared the suggested folder and it made no difference.

    I’ve called the pdf 3 different ways.
    1. From the orders page, I’m ticking the order I want to print and selecting “PDF Packing Slip” from the drop down at the top left and click Apply.
    2. From the orders page, I’ve clicked the “PDF Packing Slip” box in the actions box.
    3. In the actual order, I’ve clicked the “PDF Packing Slip” in the right side of the screen.

    All 3 options work when in Output to HTML but not as PDF.

    Thread Starter muttly

    (@muttly)

    I’ve just tried this and its still not working in pdf mode. When i do it in output to html it works fine.

    Thread Starter muttly

    (@muttly)

    That works perfectly, thank you very much!!

    Just for anyone else using it, you wan to use the “Name” of the attribute you want to hide, not the “slug”.

    • This reply was modified 6 years, 5 months ago by muttly. Reason: Added note about using name rather than slug
    Thread Starter muttly

    (@muttly)

    The temp folders are writable.

    To test I’ve also changed “Output to HTML” and the fonts generate correctly there. I have also checked the font files I’m using and they are embedded to PDF. I will forward the template and fonts to the address provided, thank you.

    Thread Starter muttly

    (@muttly)

    I’ve made several more attempts with this and while it works fine in the test.php

    It still does not work on the pdf generating file.

    I’ve moved the location of the file linked originally, it is now here.
    https://pretendtickets.com/28n042di0plzc6tv8jqgk9499kf52dmi/wp-content/themes/flatsome-child/woocommerce/pdf/PretendTickets/test.php

    Thread Starter muttly

    (@muttly)

    That worked perfectly. Thank you!

Viewing 15 replies - 1 through 15 (of 22 total)