post_type ) {
if ( class_exists( 'Ampforwp_Init' ) && $redux_builder_amp['amp-design-selector'] == 2) {
$file = dirname(__FILE__) . '/templates/ampforwp-wc.php';
} else {
$file = dirname(__FILE__) . '/templates/wc.php';
}
}
return $file;
}
/* Add WooCommerce elements in the page
1. Add WooCommerce container
2. Add Custom Style for WooCommerce Page
3. Add WooCommerce gallery
4. Add WooCommerce amp-carousel script
5. Remove Default Post Meta from header
6. Add WooCommerce Meta information
7. Add Product Description
*/
// 1. Add WooCommerce container
// Add container for WooCommerce elements
add_action('amp_woocommerce_after_the_content','amp_woocommerce_container_starts',9);
function amp_woocommerce_container_starts(){
echo '
' ;
}
add_action('amp_woocommerce_after_the_content','amp_woocommerce_container_ends',20);
function amp_woocommerce_container_ends() {
global $woocommerce;
if( $woocommerce->product_factory->get_product()->product_type === "variable" ) {
$get_available_variations = $woocommerce->product_factory->get_product()->get_available_variations();
$total_vartiants = count($get_available_variations);
?>
' ; }
add_action('amp_woocommerce_before_the_content','amp_woocommerce_bfr_content');
function amp_woocommerce_bfr_content() {
// end of if condition for variant check
} // end of amp_woocommerce_bfr_content()
// 2. Add Custom Style for WooCommerce Page
add_action('amp_post_template_css','amp_woocommerce_custom_style');
function amp_woocommerce_custom_style() {
if ( function_exists( 'is_on_sale' ) ) {
global $woocommerce;
$amp_woocommerce_sale = $woocommerce->product_factory->get_product()->is_on_sale();
if ( $amp_woocommerce_sale == 1 ) { ?>
.amp-wp-article-featured-image::before {
content: 'Sale';
background: #0a89c0;
padding: 20px 15px;
border-radius: 50%;
color: #fff;
position: relative;
z-index: 1;
left: 5%px;
top: 30px;
}
.amp-woocommerce-container amp-carousel {
background: none;
}
.amp-wp-meta.amp-woocommerce-add-cart{
display: block;
}
.amp-wp-article .ampforwp-add-to-cart-button a{
color:#fff
}
input,select{vertical-align:middle}
*,*:after,*:before {box-sizing: border-box;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;-ms-box-sizing: border-box;-o-box-sizing: border-box;}
.wcv-main-container{
width:100%;
display:inline-block
}
.amp-buttons{
width:50%;
padding:10px;
height:auto;
float:left;
line-height:0;
}
.amp-img > img{
width:100%;
height:auto;
}
.amp-img{
position:relative;
}
.price{
position:absolute;
top:15px;
right:15px;
bottom:auto;
}
.price{
background:#ccc;
padding:20px 20px;
margin-top:20px;
}
.add-cart {
bottom: 40px;
position: absolute;
right: 15px;
}
.amp-img {
margin-top: 20px;
}
.product-size {
text-align: center;
}
.amp-wp-meta.amp-woocommerce-price {
float: left;
width: 50%;
}
.amp-wp-meta.amp-woocommerce-add-cart {
float: left;
width: 50%;
text-align:right;
}
.Add-to-cart {
float: right;
width: 20%;
text-align:right;
font-size:12px;
}
.add-cart a {
background: #0a89c0;
padding: 10px 20px;
border-radius: 60px;
color: #fff;
}
.amp-wp-content{
font-size:13px;
padding:8px 10px;
}
.amp-wp-content, .amp-wp-title-bar div, .amp-woocommerce-container {
clear: both;
}
.amp-woocommerce-container > div {
padding-top: 20px;
}
.ampforwp-add-to-cart-button {
display: block;
}
.amp-wp-content.the_content.amp-wp-article-content p {
text-align: justify;
}
.varients-title {
text-align: center;
margin-top: 20px;
}
.varients-title h3 {
color: #373737;
font-size: 16px;
letter-spacing: 0.5px;
margin: 0;
}
.ampforwp-add-to-cart-button a {
background: #0a89c0;
color: #fff;
padding: 7px 20px;
text-decoration: none;
border-radius: 40px;
}
.amp-woocommerce-meta-info {
display: inline-block;
width: 100%;
padding:10px;
}
.amp-woocommerce-meta-info .amp-wp-meta{
font-size:15px;
}
/* responsive styles for mobile */
@media (max-width:767px){
.amp-wp-content, .amp-wp-content.post-title-meta.amp-wp-article-header{
width: 100%;
padding:0 10px;
}
.amp-img {
margin-top: 14px;
}
.amp-buttons {
width:50%;
padding-bottom: 5px;
}
.price {
font-size: 9px;
margin-top: 5px;
padding: 11px;
top:0px;
}
.product-size {
font-size: 13px;
}
.add-cart {
bottom: 25px;
font-size: 11px;
left: 0;
margin: 0 auto;
position: absolute;
right: 0;
text-align: center;
top: auto;
}
.amp-conatiner {
clear: both;
margin: 0 auto;
width: 100%;
}
.add-cart a {
padding: 4px 8px;
}
.product-size {
padding-top: 10px;
}
.amp-wp-meta.amp-woocommerce-price {
float: left;
}
.amp-wp-meta.amp-woocommerce-add-cart {
display:block;
float: left;
text-align: center;
}
.Add-to-cart {
float: right;
font-size: 12px;
text-align: right;
width: 30%;
}
.amp-wp-content, .amp-wp-content.post-title-meta.amp-wp-article-header {
clear: both;
}
.amp-wp-content.the_content.amp-wp-article-content p {
text-align: justify;
line-height:21px;
}
.amp-woocommerce-container > div {
padding-top: 10px;
}
}
@media (min-width:768px) and (max-width:979px){
.amp-wp-content{
width: 750px;
}
.price {
margin-top: 5px;
}
}
@media (min-width:980px) and (max-width:1199px){
.amp-wp-content{
width: 950px;
}
}
@media (min-width:480px) and (max-width:767px){
.amp-buttons {
width: 50%;
}
.price {
top: 10px;
}
.price {
font-size: 14px;
padding: 15px;
}
.add-cart a {
padding: 6px 15px;
}
.product-size {
padding-top: 20px;
}
.amp-wp-meta.amp-woocommerce-price {
width: 50%;
}
.amp-wp-meta {
font-size: 12px;
}
.amp-wp-meta.amp-woocommerce-add-cart {
float: left;
text-align: right;
}
}
.amp-wp-article .add-cart a{
color:#fff
}
.ampwc-noimg-varients .add-cart{
position: relative;
text-align:center;
bottom: 0;
right: 0;
}
.ampwc-noimg-varients{
display: inline-block;
margin-bottom: 15px;
}
.ampwc-noimg-varients .product-size{ float: none;
margin-right: 7px;
display: block;
margin-bottom: 30px;}
.ampwc-noimg-varients .amp-img{float:none}
.ampwc-noimg-varients .add-cart a{padding:6px 16px}
product_factory->get_product()->get_gallery_attachment_ids();
if ( $amp_woocommerce_gallery ) { ?>
post_type ) {
// add_filter( 'amp_post_article_footer_meta', 'amp_woocommerce_remove_comment_button' );
// }
// function amp_woocommerce_remove_comment_button( $meta_parts ) {
// foreach ( array_keys( $meta_parts, 'meta-comments-link', true ) as $key ) {
// unset( $meta_parts[ $key ] );
// }
// return $meta_parts;
// }
// 6. Add WooCommerce Meta information
add_filter( 'amp_post_article_header_meta', 'amp_woocommerce_add_wc_meta' );
function amp_woocommerce_add_wc_meta( $meta_parts ) {
$meta_parts[] = 'amp-woocommerce-meta-info';
return $meta_parts;
}
add_filter( 'amp_post_template_file', 'amp_woocommerce_add_wc_meta_path', 10, 3 );
function amp_woocommerce_add_wc_meta_path( $file, $type, $post ) {
if ( 'amp-woocommerce-meta-info' === $type && 'product' === $post->post_type ) {
$file = dirname( __FILE__ ) . '/templates/amp-woocommerce-meta-info.php';
}
return $file;
}
// 7. Add Product Description
add_action('amp_woocommerce_after_the_content','amp_woocommerce_add_product_description', 11);
function amp_woocommerce_add_product_description(){
woocommerce_template_single_excerpt();
}