I am a bit of a beginner in php and I am trying to target 3 text outputs in a php file and give them a unique class so I can style them via css.
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
$customer_id = get_current_user_id();
if ( ! wc_ship_to_billing_address_only() && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) {
$page_title = apply_filters( 'woocommerce_my_account_my_address_title', __('My Addresses:', 'woocommerce') );
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
'billing' => __( 'Billing Address:', 'woocommerce' ),
'shipping' => __( 'Shipping Address:', 'woocommerce' )
), $customer_id );
} else {
$page_title = apply_filters( 'woocommerce_my_account_my_address_title', __( 'My Address:', 'woocommerce' ) );
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
'billing' => __( 'Billing Address:', 'woocommerce' )
), $customer_id );
}
$col = 1;
?>
I am trying to target ‘My Addresses:’ as well as ‘Billing Address:’ and ‘Shipping Address:’.
I have worked with this just a bit before and I never had to add a class inside php code, but surely it must be possible, but I can’t seem to find any info on where exactly to add my div class, p class etc..
Any help would be greatly appreciated!
Thanks a lot,
Vaya
You can use the woocommerce filters to wrap it with whatever you want. Put something like this in your functions.php:
Remeber that if these elements are unique, the id attribute could be a better option.
Hope it helps!
if you go to
woocommerce/templates/myaccount/my-address.php
in line 42, you must have code like below:
change code to:
That will do the trick.