将Html转换为PHP

时间:2013-07-31 15:37:05

标签: php html wordpress

任何人都可以帮助我将Html转换为PHP

我想在我的woocommerce网站上添加一个paypal按钮,但我遇到了一些错误。

这是我用html格式的代码

<a class="paypal_checkout_button" href="websitelinkhere"><img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" width="145" height="42" style="width: 145px; height: 42px; padding-top: 30px; padding-left:20px; " border="0" align="top" alt="Check out with PayPal"></a>

基本上我正在使用主题 - theretailer.getbowtied.com/demo主页顶部的购物车下拉列表我试图将按钮添加到那个但是不能让它显示 任何帮助都会很棒

编辑*

这是我尝试将代码添加到

的页面
 <div class="gbtr_minicart_wrapper">
 <div class="gbtr_minicart">

<?php echo '<a class="paypal_checkout_button" href="websitelinkhere"><img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" width="145" height="42" style="width: 145px; height: 42px; padding-top: 30px; padding-left:20px; " border="0" align="top" alt="Check out with PayPal"></a>';?>

<?php                                    
echo '<ul class="cart_list">';                                        
if (sizeof($woocommerce->cart->cart_contents)>0) : foreach ($woocommerce->cart->cart_contents as $cart_item_key => $cart_item) :

 $_product = $cart_item['data'];                                            
 if ($_product->exists() && $cart_item['quantity']>0) :                                            
      echo '<li class="cart_list_product">';                                                
      echo '<a class="cart_list_product_img" href="'.get_permalink($cart_item['product_id']).'">' . $_product->get_image().'</a>';                                                    
      echo '<div class="cart_list_product_title">';
      $gbtr_product_title = $_product->get_title();
      //$gbtr_short_product_title = (strlen($gbtr_product_title) > 28) ? substr($gbtr_product_title, 0, 25) . '...' : $gbtr_product_title;
      echo '<a href="'.get_permalink($cart_item['product_id']).'">' . apply_filters('woocommerce_cart_widget_product_title', $gbtr_product_title, $_product) . '</a>';
       echo '<div class="cart_list_product_quantity">'.__('Quantity:', 'theretailer').' '.$cart_item['quantity'].'</div>';
       echo '</div>';
       echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf('<a href="%s" class="remove" title="%s">&times;</a>', esc_url( $woocommerce->cart->get_remove_url( $cart_item_key ) ), __('Remove this item', 'woocommerce') ), $cart_item_key );
       echo '<div class="cart_list_product_price">'.woocommerce_price($_product->get_price()).'</div>';
       echo '<div class="clr"></div>';                                                
       echo '</li>';                                         
       endif;                                        
      endforeach;
?>

<div class="minicart_total_checkout">                                        
<?php _e('Cart subtotal', 'theretailer'); ?><span>
<?php echo $woocommerce->cart->get_cart_total(); ?></span>                                   
</div>


<a href="<?php echo esc_url( $woocommerce->cart->get_cart_url() ); ?>" class="button gbtr_minicart_cart_but"><?php _e('View Shopping Bag', 'theretailer'); ?></a>   
<a href="<?php echo esc_url( $woocommerce->cart->get_checkout_url() ); ?>" class="button gbtr_minicart_checkout_but"><?php _e('Proceed to Checkout', 'theretailer'); ?></a>

  <?php                                        
  else: echo '<li class="empty">'.__('No products in the cart.','woocommerce').'</li>'; endif;                                    
   echo '</ul>';                                    
   ?>                                                                        

   </div>
   </div>

   </div>

  <a href="<?php echo esc_url( $woocommerce->cart->get_cart_url() ); ?>" class="gbtr_little_shopping_bag_wrapper_mobiles"><span><?php echo $woocommerce->cart->cart_contents_count; ?></span></a>

   </div>

我正在寻找按钮

我正在寻找它进入按钮

下的gbtr_minicart部分

2 个答案:

答案 0 :(得分:4)

你去吧

//some php code
?>
    <a class="paypal_checkout_button" href="websitelinkhere"><img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" width="145" height="42" style="width: 145px; height: 42px; padding-top: 30px; padding-left:20px; " border="0" align="top" alt="Check out with PayPal"></a>
<?php
//php code again

答案 1 :(得分:0)

<?php 
  echo '<a class="paypal_checkout_button" href="websitelinkhere"><img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" width="145" height="42" style="width: 145px; height: 42px; padding-top: 30px; padding-left:20px; " border="0" align="top" alt="Check out with PayPal"></a>';

?>