Woocommerce – Checkout error message

you can try it for address not required . add_filter( ‘woocommerce_billing_fields’, ‘wc_optional_billing_fields’, 10, 1 ); function wc_optional_billing_fields( $address_fields ) { $address_fields[‘billing_address_1’][‘required’] = false; $address_fields[‘billing_address_2’][‘required’] = false; return $address_fields; }

Shortcode to include PHP file, pass various parameters to include?

Thanks for your comments and guidance. I implemented solutions which didn’t reinvent the wheel. The complication was finding a way to remove the [insert_php][/insert_php] wrapped code from pages and posts and still preserve the content and user experience. Custom Template Pages Pages and Posts which were almost entirely PHP were made into custom template files. … Read more

Need to use an external variable inside a function

You’re right that using globals is inelegant at best. There are almost always better solutions that don’t depend on global variables. However, if you pause execution within your file_pull() function (e.g. using a debugger), or even just print $GLOBALS to your php error log within the scope of your function, does your $type variable show … Read more

Woocommerce – Product Description heading [closed]

You can change the description tab heading to the product category followed by the name using the following snippet add_filter( ‘woocommerce_product_description_heading’, ‘product_description_tab’, 10, 1 ); function product_description_tab( $title ) { global $post, $product; $categ = $product->get_categories(); return $categ.’-‘. $post->post_title; } According to above code, you can get product brand. I hope that’ll solve your issue. … Read more

Parse error: syntax error, unexpected ‘endforeach’ (T_ENDFOREACH) in [closed]

When you use endforeach;, you have to use : instead off { when starting the foreach. <ul class=”project-extension-side-link”> <?php foreach($projectextensions as $projectextension) : // <— ?> <li <?php echo ($section==’project-extension’ ? ‘class=”active”‘: ”); ?>><span>Project 1</span></li> <li><a href=””><?php echo $projectextension->post_title; ?></a></li> <li><a href=””>Project 3</a></li> <li><a href=””>Project 4</a></li> <li><a href=””>Project 5</a></li> <li><a href=””>Project 6</a></li> <?php endforeach; ?> … Read more

Add product to cart from functions.php

I’ve figured it out function my_custom_function() { global $woocommerce; if ( $_SERVER[‘REQUEST_URI’] == ‘/checkout/?a=b’ ) { $woocommerce->cart->add_to_cart( 90759, 1 ); // exit; } } add_action( ‘init’, ‘my_custom_function’, 7 );